nadeemshafi9 Posted April 2, 2009 Share Posted April 2, 2009 hello guys i have a time 00:00:00 and a datetime 0000-00-00 11:11:00 i would like to add the time to the datetime and preserve the date prior to the add in the resultant datetime. Thanks for any help Link to comment https://forums.phpfreaks.com/topic/152224-add-time-to-datetime/ Share on other sites More sharing options...
Yesideez Posted April 2, 2009 Share Posted April 2, 2009 int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) $thetme='00:00:10'; $justTime=mktime(substr($thetime,0,2),substr($thetime,3,2),substr($thetime,6,2),0,0,0); $dateTime=strtotime('0000-00-00 11:11:00'); $addedtogether=$dateTime+$justTime; echo date('d-M-Y H:i:s',$addedtogether); See how that works. Link to comment https://forums.phpfreaks.com/topic/152224-add-time-to-datetime/#findComment-799375 Share on other sites More sharing options...
nadeemshafi9 Posted April 2, 2009 Author Share Posted April 2, 2009 int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) $thetme='00:00:10'; $justTime=mktime(substr($thetime,0,2),substr($thetime,3,2),substr($thetime,6,2),0,0,0); $dateTime=strtotime('0000-00-00 11:11:00'); $addedtogether=$dateTime+$justTime; echo date('d-M-Y H:i:s',$addedtogether); See how that works. thnaks man il try it out tommorow Link to comment https://forums.phpfreaks.com/topic/152224-add-time-to-datetime/#findComment-799756 Share on other sites More sharing options...
MadTechie Posted April 2, 2009 Share Posted April 2, 2009 why now just $thetime='00:00:10'; $dateTime='0000-00-00 11:11:00'; echo date('d-M-Y H:i:s',(strtotime($dateTime) + strtotime($thetime) ) ); Link to comment https://forums.phpfreaks.com/topic/152224-add-time-to-datetime/#findComment-799761 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.