lkh11lkh Posted February 23, 2009 Share Posted February 23, 2009 hi if my $date is 2009-02-21 01:30:00 if my $signup_date is 2009-02-21 01:00:00 the total is 30minutes. How do i use php code to do $date - $singup_date? is there any help? thanks alot lkh Link to comment https://forums.phpfreaks.com/topic/146564-how-do-i-use-php-code-to-do-date-singup_date/ Share on other sites More sharing options...
premiso Posted February 23, 2009 Share Posted February 23, 2009 If you are pulling this from mysql, use that to do it given the function DATE_SUB. Link to comment https://forums.phpfreaks.com/topic/146564-how-do-i-use-php-code-to-do-date-singup_date/#findComment-769422 Share on other sites More sharing options...
sasa Posted February 23, 2009 Share Posted February 23, 2009 http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_timediff Link to comment https://forums.phpfreaks.com/topic/146564-how-do-i-use-php-code-to-do-date-singup_date/#findComment-769431 Share on other sites More sharing options...
lkh11lkh Posted February 23, 2009 Author Share Posted February 23, 2009 thanks premiso & sasa but i still did not understand . is it i must convert $date & $signup_date into unix_timestamp? if yes, is there sample or example link? thanks Link to comment https://forums.phpfreaks.com/topic/146564-how-do-i-use-php-code-to-do-date-singup_date/#findComment-769441 Share on other sites More sharing options...
l0ve2hat3 Posted February 23, 2009 Share Posted February 23, 2009 <?php $date = "2009-02-21 01:30:00"; $signup_date= "2009-02-21 01:00:00"; echo (strtotime($date)-strtotime($signup_date))/60; ?> Link to comment https://forums.phpfreaks.com/topic/146564-how-do-i-use-php-code-to-do-date-singup_date/#findComment-769450 Share on other sites More sharing options...
lkh11lkh Posted March 3, 2009 Author Share Posted March 3, 2009 hi <?php $date = "2009-02-21 01:30:00"; $signup_date= "2009-02-21 00:00:00"; echo (strtotime($date)-strtotime($signup_date))/60; ?> if total is 90mins how do i convert from 90mins to 1hr 30mins? thanks for your help Link to comment https://forums.phpfreaks.com/topic/146564-how-do-i-use-php-code-to-do-date-singup_date/#findComment-775373 Share on other sites More sharing options...
jitesh Posted March 3, 2009 Share Posted March 3, 2009 $var = 90; // mins $str = floor($var/60)." hours ".($var%60)." mins"; Link to comment https://forums.phpfreaks.com/topic/146564-how-do-i-use-php-code-to-do-date-singup_date/#findComment-775383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.