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 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. 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; ?> 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); 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 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 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); 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 ..... Link to comment https://forums.phpfreaks.com/topic/247535-date-convert-from-sql/#findComment-1271157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.