shane85 Posted April 1, 2010 Share Posted April 1, 2010 hey guys in my mysql db I have a field tstamp...I have it so when the form is submitted and info is entered into the database, it ads the timestamp. Im trying to show the tstamp on my page, however its not displaying the same date thats in my database. In my database, I have one of the dates as 2010-04-01 12:23:15 im trying to access it by <?php echo date('M, d - Y', $arrEntry['tstamp']); ?> however, regardless of whats actually in the database, it is displaying Dec, 31 - 1969 why would this be??? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/197279-timestamp-displaying-wrong-datehelp/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 1, 2010 Share Posted April 1, 2010 $arrEntry['tstamp'] does not contain what you think it does. Echo $arrEntry['tstamp'] to see what is actually in it. Quote Link to comment https://forums.phpfreaks.com/topic/197279-timestamp-displaying-wrong-datehelp/#findComment-1035466 Share on other sites More sharing options...
shane85 Posted April 1, 2010 Author Share Posted April 1, 2010 ah...I just noticed it wasnt in my query....currently my query is set as $prospectEntries = mysql_query('SELECT * FROM prospects WHERE prospect_id="'.$_GET['prospect_id'].'"' ) or trigger_error(mysql_error()); it has to be like that because of the other functions I have on the page. I know I need to include UNIX_TIMESTAMP(tstamp) AS tstamp but how would I incorporate that in?? thanks Quote Link to comment https://forums.phpfreaks.com/topic/197279-timestamp-displaying-wrong-datehelp/#findComment-1035467 Share on other sites More sharing options...
ialsoagree Posted April 1, 2010 Share Posted April 1, 2010 The date function expects a unix time stamp (the number of seconds since January 1st 1970 GMT). If you plan to do a lot of your date handling in PHP, it's often better to store the time in the database as an int(11) and a unix timestamp. PHP gives you the current unix time stamp with time(). If you want to convert your MySQL time to a unix timestamp, I'd suggest doing it in PHP with strtotime($mysql_date). Quote Link to comment https://forums.phpfreaks.com/topic/197279-timestamp-displaying-wrong-datehelp/#findComment-1035469 Share on other sites More sharing options...
Or1g1naL Posted April 1, 2010 Share Posted April 1, 2010 and FWIW Unix timestamps represent the number of seconds since one millisecond before midnight Jan. 1 (i.e. Dec 31, 1969 11:59:59.999) Quote Link to comment https://forums.phpfreaks.com/topic/197279-timestamp-displaying-wrong-datehelp/#findComment-1035474 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.