Page 1 of 1
[SOLVED] Formatting DateTime
Posted: Wed Aug 25, 2004 8:28 pm
by AliasBDI
I cannot seem to get this right. Am I coding it correctly?
Code: Select all
<?php $created = $row_userLIST['date_created']; echo strtotime("l dS of F Y h:i:s A", $created); ?>
Its returning a TIMESTAMP and another one is DATETIME fields. It is giving me '-1' and that is it.
Posted: Wed Aug 25, 2004 8:33 pm
by tim
the way you have it you'll want to use date() instead of strtotime
Worked!!
Posted: Wed Aug 25, 2004 8:40 pm
by AliasBDI
Is there a shorter way of coding this? So I can apply the date() function to the echo of the $row rather than declaring the $row as a $variable first?
Posted: Wed Aug 25, 2004 8:43 pm
by markl999
Code: Select all
echo date('l dS of F Y h:i:s A', $row_userLIST['date_created']);
Posted: Wed Aug 25, 2004 8:43 pm
by tim
date('l dS of F Y h:i:s A', $row_userLIST['date_created']);
Superb...
Posted: Wed Aug 25, 2004 8:45 pm
by AliasBDI
Now my dates and times are way off - up in the future - when they should be today. Is there a way to check my server time to see if it is off? Or is this a problem with my code saying the date wrong?
It reads: Monday 18th of January 2038 09:14:07 PM
Posted: Wed Aug 25, 2004 8:48 pm
by markl999
What does echo $row_userLIST['date_created']; output?
this
Posted: Wed Aug 25, 2004 8:49 pm
by AliasBDI
20040825192940
It is a TIMESTAMP column. I'm also doing this to a DATETIME column.
Posted: Wed Aug 25, 2004 8:52 pm
by markl999
That's not a Unix Timestamp, and that's what date requires. In your query use SELECT UNIX_TIMESTAMP(date_created) ... to get a unix timestamp.
Posted: Wed Aug 25, 2004 8:54 pm
by tim
u need a unix time-stamp for that, generally its easier to use the mysql side of things for it
edit - why i even bother when a shooter like mark is around =]
Posted: Wed Aug 25, 2004 9:03 pm
by AliasBDI
Didn't do a darn thing. Here is my query:
Code: Select all
SELECT UNIX_TIMESTAMP(date_created), id, username, domain, email, level, date_created, date_lastlogin, active FROM user_info
Does it matter that I'm on a Windows 2000 server?
Posted: Wed Aug 25, 2004 9:18 pm
by feyd
Code: Select all
SELECT *, UNIX_TIMESTAMP(date_created) date_created FROM user_info
Posted: Wed Aug 25, 2004 9:26 pm
by AliasBDI
Super. Pure genious are you guys. Thanks for the help!
Posted: Mon Aug 30, 2004 2:13 pm
by AliasBDI
Moderator....problem solved!
Posted: Mon Aug 30, 2004 4:36 pm
by timvw
If the timestamp came from a query, the laziest soluition would have been:
SELECT DATE_FORMAT(timestamp, '%Y-%m%d %h:%i:%s') AS timestamp FROM table;