Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-22-2005, 06:51 PM TIMESTAMP Issue
Junior Talker

Posts: 2
Trades: 0
Hi,
I'm having some problems with the following:

$query = "SELECT * FROM table ORDER BY date DESC";
$result = mysql_query($query);
$result_row = mysql_fetch_assoc($result);
$time = strtotime($result_row['date']);
$date = date("F jS, Y g:i:s A", $time);
echo $date;

So, if say one row in my database had a date TIMESTAMP of 20050214120000, it should display as February 14th, 2005 12:00:00 PM. Instead, the code displays all row dates as December 31st, 1969 3:59:59 PM. Can someone help me with this or point me in a direction. Thanks!
jlindquist is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-22-2005, 07:54 PM
camperjohn's Avatar
Ultra Talker

Posts: 268
Location: San Diego
Trades: 0
Your timestamp is not in unix form, and that is what date is expecting. Feb 14 is actually 1108339200 (seconds since 1970 I think?)

Instead of using the "date" function, you need to split your string, as the first 4 are year, then month etc...

Use the substr function instead:

http://us4.php.net/manual/en/function.substr.php
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
camperjohn is offline
Reply With Quote
View Public Profile Visit camperjohn's homepage!
 
Old 03-22-2005, 08:19 PM
Junior Talker

Posts: 2
Trades: 0
camperjohn,

Thank you for responding. I will take a look at the substr function and give that a try. Thanks!
jlindquist is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to TIMESTAMP Issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.44131 seconds with 12 queries