Jump to content

timestamp displaying wrong date...help


shane85

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/197279-timestamp-displaying-wrong-datehelp/
Share on other sites

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

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.