Quote:
Originally Posted by LearningCoder
What format is the date stored in the database? Is it just a timestamp?
Regards,
LC.
|
Quote:
Originally Posted by Fou-Lu
Sounds to me that its stored in a date/datetime datatype if you can view it directly from pulling a db record.
That means your result of calling the date function will result in either December 31, 1969 or January 1, 1970 depending on your timezone (its currently at unix epoch).
Therefore you cannot use the date() function directly as it requires an integer timestamp. Your options are either to: - Format the date in the query
- Use the UNIX_TIMESTAMP function in MySQL to convert it to a timestamp
- Split the parts up and use the mktime function
- Run the result through an strtotime or DateTime object to convert it to an appropriate timestamp. Then use date or DateTime::format on it.
|
It is stored in a timestamp format, but is still displaying December 31, 1969 4:33 PM
EDIT:Still not sure what was the issue but got it displaying the correct date by calling it through the strotime() function.
__________________
Coding is a challenge, get used to it
Always remember to debug
Try the guess & check method
Break it down into simple steps
Last edited by elitis; 12-10-2012 at 06:37 PM..
|