Hi all,
Another issue I am having at the moment is with dates and times. On the site in question, I am inserting into the database using an EE SAEF, and the fields are a date/time format.
So, when I select 10AM, I insert the entry, and when I look at the entry in the System (edit page), the date shows as 10AM.
However… when I try to display the time on the website again, I am using php’s date function, and it is showing 00AM
The same thing happens for all times, in EE edit screen, they display fine, but on the site, they are 10hours out.
What is the cause of this? Shouldn’t a timestamp be a timestamp? Does it have something to do witht he localization settings? I have checked the system prefs and the timezone is UP8, I have checked my account prefs and the timezone is UP8. I have put in some code to test the server time, local time and user time, and all 3 say UP8.
If I use date_default_timezone_set(‘Australia/Perth’), the times change to 9 hours out instead of 10. Any help with this would be much appreciated :D
Thanks
Patrick
*edit*
ok, I have echoed the timestamp as it appears in the database, and I am getting the incorrect time when i put that timestamp into an online converter… so, does EE store the dates in a different format? or will there be a setting somewhere that is causing the errors?
*edit 2*
i have just echoed strtotime(‘now’), and put that into the convertor, and that is accurate. So the issue is with pulling it from the database once ee has inserted it. It is inserting the right time, and in the system it shows the right time, so i must be doing something wrong when i pull it out… i am using
date('Y-m-d H:i s', $row['field_id_21']);where $row is pulled from the db…
* edit 3*
this is getting more and more weird…
same time: 10AM entered.
in the system, it displays 10am. the following code:
echo '{exp:weblog:entries weblog="timesheet" entry_id="' . $entry_id . '"}EE Time: {ts_start format="%Y-%m-%d %H:%i:%s"}{/exp:weblog:entries}
PHP Time: ' . date('Y-m-d H:i:s', $row['start']) . '';displays:
EE Time: 2007-08-14 08:00:00
PHP Time: 2007-08-14 00:00:00
so now i have 3 different times, and the only one correct is the system one.