jschofield Posted May 1, 2007 Share Posted May 1, 2007 Hello all, I am pulling a date from a flat file that is 4/17/07. I am trying to convert this into 04/17/2007. This is how I am doing this. outdate = date("m/d/Y" , $vals[16]); The $vals[16] is where the date is located at in my file. The output I get is the same format that is in my file before converting. So pretty much my converting of the date does nto work. Anyone have any ideas? Please help. Thanks everyone. Johnnie Link to comment https://forums.phpfreaks.com/topic/49560-date-format/ Share on other sites More sharing options...
clown[NOR] Posted May 1, 2007 Share Posted May 1, 2007 this worked for me <?php $date = explode("/", "4/17/07"); $month = $date[0]; $day = $date[1]; $year = $date[2]; echo date("m/d/Y", mktime(0, 0, 0, $month, $day, $year)); ?> Link to comment https://forums.phpfreaks.com/topic/49560-date-format/#findComment-242958 Share on other sites More sharing options...
Barand Posted May 1, 2007 Share Posted May 1, 2007 <?php $d = '4/17/07'; $formatted = date('m/d/Y', strtotime($d)); echo $formatted; ?> Link to comment https://forums.phpfreaks.com/topic/49560-date-format/#findComment-243007 Share on other sites More sharing options...
clown[NOR] Posted May 2, 2007 Share Posted May 2, 2007 hehe... or you can to it like that Link to comment https://forums.phpfreaks.com/topic/49560-date-format/#findComment-243026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.