MasterACE14 Posted February 8, 2008 Share Posted February 8, 2008 Hey, I'm having some trouble with the Time and Date, I'm not sure if I am inserting the right time/date into the database in a Integer column. But I'm also not 100% sure that I am echo'ing the time/date right either. Basically what I do is insert time(); into the database, and then retrieve it and format it with this code: <?php // workout Time $datetime = $row["time"]; $year = substr( $datetime, 0, 4 ); $mon = substr( $datetime, 4, 2 ); $day = substr( $datetime, 6, 2 ); $hour = substr( $datetime, 8, 2 ); $min = substr( $datetime, 10, 2 ); $sec = substr( $datetime, 12, 2 ); $orgdate = date("F j, Y", mktime( $hour, $min, $sec, $mon, $day, $year ) ); // and I echo this: echo date("F j, Y", strtotime($datetime)); but it keeps echoing December 31, 1969 I'm not sure if I'm inserting the incorrect time/date into the database, or if I'm echoing is incorrect? any help is greatly appreciated. Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/90128-solved-trouble-with-time-and-date/ Share on other sites More sharing options...
schilly Posted February 8, 2008 Share Posted February 8, 2008 Is that PHP time() or SQL time()? Can't remember if they are the same. If it's PHP just do: <?php // workout Time $datetime = $row["time"]; $orgdate = date("F j, Y", $datetime); echo $orgdate; Not sure why you used strtotime when the time column in the db is an int. Quote Link to comment https://forums.phpfreaks.com/topic/90128-solved-trouble-with-time-and-date/#findComment-462223 Share on other sites More sharing options...
MasterACE14 Posted February 9, 2008 Author Share Posted February 9, 2008 Thats worked! thanks heaps Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/90128-solved-trouble-with-time-and-date/#findComment-462270 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.