Jump to content

Archived

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

foreverhex

Wierd date() output

Recommended Posts

Ok so Ive have never used the date() function before untill now. I thought I had it all down (simple it seemed) but some how I getting something weird.

[code]$signupdate = date("F d Y" , $row["signupdate"]);
$lastlogin = date("F d Y" , $row["lastlogin"]);[/code]

The $row["signupdate"] and $row["lastlogin"] are from a MySQL query and it out put something like this normally: 2006-07-12 23:28:57.

But when I load the page it comes out as: December 31 1969. ???? Why, what, no! Any ideas?

Share this post


Link to post
Share on other sites
i think its because the date() functions have diff things like for the dates and stuff i will get u the right form brb

Share this post


Link to post
Share on other sites
Are you trying to get rid of the time in the $row
if so use str_replace or eregi_repalce or substr

Share this post


Link to post
Share on other sites
http://us2.php.net/date

thats the page with all the date forms and stuff u have the "F" which displays the word form

Share this post


Link to post
Share on other sites
The date() function is expecting a UNIX timestamp as the second parameter, not a string. A UNIX timestamp is the number of seconds since 1-1-1970 for the date. To get this number you can use the strtotime() function. So in your case:
[code]<?php
$signupdate = date("F d Y" , strtotime($row["signupdate"]));
$lastlogin = date("F d Y" , strtotime($row["lastlogin"]));
?>[/code]

Ken

Share this post


Link to post
Share on other sites
an alternative is to pull the date using MySQL's UNIX_TIMESTAMP() function directly.

Share this post


Link to post
Share on other sites

×

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.