Forum Moderators: coopster

Message Too Old, No Replies

makeDateTime function not working :-(

it's not 12/31/69... or is it?

         

stuckinbed

9:13 pm on Apr 10, 2005 (gmt 0)

10+ Year Member



here is the code:

echo makeDateTime($row_rs_event_data['ts'], 'D, n/j g:ia');

it keeps producing 12/31/69 even though the timestamp in the mysql database is set correctly. what is wrong?

thanks for your help!

mipapage

9:33 pm on Apr 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey there,

I'm not sure if I'm outta whack here, but looking at the php date [php.net] function and what you have there I think I can see the problem. This should work, I would think:

echo date("D, n/j g:ia", $row_rs_event_data['ts']);

stuckinbed

9:59 pm on Apr 10, 2005 (gmt 0)

10+ Year Member



thanks... but now it thinks it's Jan 18 2038 with the following code

echo date("D, n/j g:ia Y", $row_rs_event_data['ts']);

hmm... maybe it's not reading the timestamp correctly?

mipapage

10:07 pm on Apr 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> maybe it's not reading the timestamp correctly?

I find, that when I get to the "php isn't working right stage", I need to take a step back and look elsewhere, because everytime I've had an argument with PHP (once a week, maybe), in the end it was right ;-)

Perhaps your timestamp is wrong? I'm not sure, if you happen to have other "date data", you could verify your timestamp against the value output from mktime() [php.net].

stuckinbed

11:07 pm on Apr 10, 2005 (gmt 0)

10+ Year Member



thanks,

guess i'll have to find another way to do the same thing

shouldn't be a problem... cause there's always a million ways to do one thing anyway

gettopreacherman

7:42 pm on Apr 11, 2005 (gmt 0)

10+ Year Member



The 12/69 thing is because it's a date earlier than 1/1/1970...anything older, ya gotta do your own...I had to on my site, it was a bit of a bear.

dreamcatcher

8:03 pm on Apr 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are using a TIMESTAMP field in your db and have the data stored using now(), use the UNIX_TIMESTAMP function to retrieve.

$query = mysql_query("SELECT UNIX_TIMESTAMP(ts) as new_date FROM table");
$row = mysql_fetch_object($query);

Then use the date function with the optional timestamp parameter:

echo date("D, n/j g:ia", $row->new_date);

dc