mssakib Posted September 20, 2011 Share Posted September 20, 2011 Hi In sql we have dates like this 134238 In php it shows - 19:10:11 . we can make it by using date('d.m.y', $date); where $date=134238 ; my question is how can we turn 19:10:11 in to 134238 using PHP Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/ Share on other sites More sharing options...
Pikachu2000 Posted September 20, 2011 Share Posted September 20, 2011 None of that makes any sense. How about posting actual code and real values instead of expecting people to guess what you're doing. Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271141 Share on other sites More sharing options...
xyph Posted September 20, 2011 Share Posted September 20, 2011 is 19:10:11 dd:mm:yy or hh:mm:ss ? If it's DD:MM:YY you'd use <?php $date = '19:10:11'; list( $day,$month,$year ) = explode( ':', $date, 3 ); $stamp = mktime(0,0,0,$month,$day,$year); echo $stamp; ?> Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271143 Share on other sites More sharing options...
dougjohnson Posted September 20, 2011 Share Posted September 20, 2011 Human readable to UTC example: 1316549989 = mktime(15,19,49,09,20,2011) $utctime = mktime($hour,$minutes,$seconds,$month,$day,$year); ------------------------------- UTC to Human readable example: 2011-09-20 15:19:49 = date('Y-m-d G:i:s',1316549989) $humanreadabletime = date('Y-m-d G:i:s',$actual_utc_time); Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271151 Share on other sites More sharing options...
mssakib Posted September 20, 2011 Author Share Posted September 20, 2011 But i want to do reverse... how to do that Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271153 Share on other sites More sharing options...
mssakib Posted September 20, 2011 Author Share Posted September 20, 2011 SOLVED ... thx to xyph Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271154 Share on other sites More sharing options...
dougjohnson Posted September 20, 2011 Share Posted September 20, 2011 19:10:11 $date_entered = "19:10:11"; $dateexplode = explode(':',$date_entered); $year = $dateexplode[2]; //$year = 11 $month = $dateexplode[1]; //$month = 10 $day = $dateexplode[0]; //$day = 19 $convert = mktime(0,0,0,$month,$day,$year); Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271156 Share on other sites More sharing options...
mssakib Posted September 20, 2011 Author Share Posted September 20, 2011 SOLVED though thx bro ..... Quote Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271157 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.