foreverhex Posted July 14, 2006 Share Posted July 14, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/ Share on other sites More sharing options...
BillyBoB Posted July 14, 2006 Share Posted July 14, 2006 i think its because the date() functions have diff things like for the dates and stuff i will get u the right form brb Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58185 Share on other sites More sharing options...
redarrow Posted July 14, 2006 Share Posted July 14, 2006 Are you trying to get rid of the time in the $row if so use str_replace or eregi_repalce or substr Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58187 Share on other sites More sharing options...
BillyBoB Posted July 14, 2006 Share Posted July 14, 2006 http://us2.php.net/datethats the page with all the date forms and stuff u have the "F" which displays the word form Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58188 Share on other sites More sharing options...
BillyBoB Posted July 14, 2006 Share Posted July 14, 2006 did this help u? Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58189 Share on other sites More sharing options...
kenrbnsn Posted July 15, 2006 Share Posted July 15, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58198 Share on other sites More sharing options...
foreverhex Posted July 15, 2006 Author Share Posted July 15, 2006 Cool thx kenrbnsn. That what it was. Thank you alot! Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58225 Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 an alternative is to pull the date using MySQL's UNIX_TIMESTAMP() function directly. Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58236 Share on other sites More sharing options...
ShogunWarrior Posted July 15, 2006 Share Posted July 15, 2006 Yeah, e.g: "SELECT UNIX_TIMESTAMP(date) as timestamp" Quote Link to comment https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58245 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.