Friday, September 19, 2008

How to add date and time using php - mktime()

When you need to add time or add date, you don't need to explode your time string and add time or date separately for each part, you can simply use php's powerful mktime() function to do all the work.


echo 'Original Date/Time <br />';


echo date("h:i:s d-m-Y", mktime(10, 15, 20, 8, 20, 2008));
//10:15:20 20-08-2008

echo '<br /><br />';

echo 'Date/Time Added by 1';
echo '<br />';

echo date("h:i:s d-m-Y", mktime(10+1, 15+1, 20+1, 8+1, 20+1,2008+1));
//11:16:21 21-09-2009


Get Free Sinhala IT Learning Videos

Subscribe To My Blog

No comments:

Post a Comment