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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.