otuatail Posted February 7, 2009 Share Posted February 7, 2009 Hi I am trying to convert a date to a 10 digit unix time stamp and insert it intoi a databse, and to read it back. The mktime() function strangly wants the american version of 'mm/dd/yy' but the results are wrong. <?php $stamp = mktime(12,30, 0, 03, 17, 2009); // 17th March 200 12:30 echo($stamp . "<br>"); $day = date("D dS M h:i a Y", $row['Stamp']); echo($day . "<br>"); ?> Results 1237293000 Thu 01st Jan 12:00 am 1970 Desmond. Link to comment https://forums.phpfreaks.com/topic/144245-solved-convert-date-time-to-unix-stamp-and-back/ Share on other sites More sharing options...
Mchl Posted February 7, 2009 Share Posted February 7, 2009 In your code $row['Stamp'] is undefined, so it is cast to integer 0 for date() Link to comment https://forums.phpfreaks.com/topic/144245-solved-convert-date-time-to-unix-stamp-and-back/#findComment-756968 Share on other sites More sharing options...
otuatail Posted February 7, 2009 Author Share Posted February 7, 2009 Apologies. Copied code out of context. It does work. Desmond. Link to comment https://forums.phpfreaks.com/topic/144245-solved-convert-date-time-to-unix-stamp-and-back/#findComment-756973 Share on other sites More sharing options...
Mchl Posted February 7, 2009 Share Posted February 7, 2009 Suspected that Cheers. Link to comment https://forums.phpfreaks.com/topic/144245-solved-convert-date-time-to-unix-stamp-and-back/#findComment-756989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.