![]() |
Date Format gone wrong
It is displaying the wrong date after being echoed but is fine when just the date is echoed as well as in the database.
PHP Code:
|
What format is the date stored in the database? Is it just a timestamp?
Regards, LC. |
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:
|
Quote:
Quote:
EDIT:Still not sure what was the issue but got it displaying the correct date by calling it through the strotime() function. |
Quote:
Timestamp in MySQL is a [more or less] datetime type that has been given an explicit range (from epoch to 32bit max [ie: January 19, 2038 @ 03:14:07; the real year 2000]). So its represented internally as a number, while datetime would be a string. When passed to PHP, it is a string, not a number. Timestamp in PHP is an integer. Using the UNIX_TIMESTAMP returns the integer timestamp result of the MySQL TIMESTAMP so that PHP can make use of it as a $timestamp in its date functions. |
| All times are GMT +1. The time now is 10:15 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.