Skip to main content

Date functions

addDate() : PHP FUNCTION TO ADD DATE

This function accepts the date in d/m/Y format
It can add days ,months and years to the supplied date
It will return future date in user supplied format.
It generates the time stamp of future date and formats it and returns.
If the supplied date is not in d/m/Y format then function will return nothing.

function addDate($inputDate,$days2Add=0,$months2Add=0,
$years2Add=0,$outputDateFormat="Y-m-d")
{
//assuming supplied date in d/m/Y change it to m/d/Y
$futuredate="";
$arrDate=@explode("/",$inputDate);
$reformedDate=$arrDate[1]."/".$arrDate[0]."/".$arrDate[2];
if( checkdate($arrDate[1],$arrDate[0],$arrDate[2]) ){
//if date is valid then return future date else return null
$id = strtotime($reformedDate);
//preserve time
$futuredate= date($outputDateFormat, mktime(date('h',$id), date('i',$id), date('s',$id), date('m',$id)+$months2Add, date('d',$id)+$days2Add, date('Y',$id)+$years2Add));
}
return $futuredate;
}


usuage:
<?php
echo( "Future Date: ".addDate($dt ,$d ,$m ,$y ,$df) );
echo( "Future Date: ".addDate("20/12/2010" ,30 ,1 ,2 ,"Y-m-d H:i:s") );
?>
Output : Future Date: 19/02/2013 12:00:00

FUNCTION PAGE

Comments

Popular posts from this blog

Intex Aqua 5.5 VR Plus genuine Review - Dont Buy Intex Aqua 5.5 VR Plus - Board complaint and low battery backup issues

Intex Aqua 5.5 VR Plus  Review - Dont Buy Intex Aqua 5.5 VR + - Board complaint and low battery backup issues I bought an Intex Aqua 5.5 VR Plus on April 23, 2018, With in a week it started to show Battery backup issues. Even if it is charged full, it will completely drain out with in 12 or 13 hours. During this time No internet was used, only 2 or 3 calls were done. Some times there was issues with net connection also.

Deep-sea Anglerfish Black Seadevil Scary looking creature Video

Deep-sea Anglerfish are the strange and elusive creature that are very rarely observed in their natural habitat. Fewer than half a dozen have ever been captured on film or video by deep-diving research vehicles.They are mostly  found in tropical to temperate waters of the Indian,Pacific and Atlantic Oceans.

How to use WiFi adapter on Ubuntu 16.04 desktop PC - Realtek RTL8188EUS 802.11n Wireless USB Network Adapter Driver installation

Installation of Realtek RTL8188EUS 802.11n Wireless USB Network Adapter on Desktop PC having Ubuntu 16.04 OS My PC is running in Ubuntu 16.04 OS, recently I thought of using a dongle wife adapter to access our home's Wifi network. For this I used Realtek RTL8188EUS 802.11n Wireless USB Network Adapter ( Model No: OT-WUA950NM ) This small device cost around Rupees 250/- to Rs 300/- in India. I did the following steps for installation of this Realtek Nano Wifi Adapter: Plug Realtek RTL8188EUS 802.11n Wireless USB Network Adapter to your PC's USB port, Take the terminal application and run the command "lsusb" to list the plugged in usb devices: Myhome:~$ lsusb Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 003: ID 0bda:8179 Realtek Semiconductor Corp. R...


Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »
Member
Search This Blog