Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone for log record datetime attribute. #94

Closed
wants to merge 1 commit into from
Closed

Timezone for log record datetime attribute. #94

wants to merge 1 commit into from

Conversation

marrrvin
Copy link

Log record datetime attribute always in UTC+0 timezone but should be in server timezone.
It's an attempt to fix it.

@Seldaek Seldaek closed this in 6cbdc04 Jun 26, 2012
@Seldaek
Copy link
Owner

Seldaek commented Jun 26, 2012

Hey, I did an alternative fix (see above), if you can try it and confirm it works as expected it'd be great. Your solution was alright but creating a DateTimeZone instance for every log entry was just not needed.

@marrrvin
Copy link
Author

Hi.

creating a DateTimeZone instance for every log entry was just not needed.

Yes, you are right.

6cbdc04 works for me.

@Seldaek
Copy link
Owner

Seldaek commented Jun 26, 2012

Glad to hear, and thanks for pointing out the problem :)

@marrrvin
Copy link
Author

Thank you )

@mlebkowski
Copy link

The timezone parameter and the current timezone are ignored when the time parameter either contains a UNIX timestamp (e.g. 946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00).
see: http://www.php.net/manual/en/datetime.createfromformat.php

Confirmation:

<?php
$timeZone = new DateTimeZone('Europe/Warsaw');

$dateFromTimestamp = DateTime::createFromFormat('U.u', sprintf("%.6f", microtime(true)), $timeZone);

$date = clone $dateFromTimestamp;
$date->setTimeZone($timeZone);

var_dump($date->format('y-m-d H:i:s') === $dateFromTimestamp->format('y-m-d H:i:s'));

So I think you should set timezone on DateTime object via setTimeZone() method.

@Seldaek
Copy link
Owner

Seldaek commented Aug 10, 2012

@mlebkowski that's how I did it in 6cbdc04 - do you have issues with the master branch?

@mlebkowski
Copy link

Oh, sorry, I was on latest stable. My bad.

@brahimrafik
Copy link

Hi everyone
I am a Mac OSX user and I am having a problem with the time zone (I live in Tunis I tried ids like 47 and 86 even 94 but always the same error..)
screen shot 2013-12-07 at 7 36 17 pm

@stof
Copy link
Contributor

stof commented Dec 7, 2013

Set the date.timezone in your php.ini file or through ini_set at the very beginning of your script if you cannot change your php.ini.
without a proper timezone set in your php.ini, you will get issues as soon as you create a datetime instance (ie before your call to setTimezone)

@brahimrafik
Copy link

sorry but could you explain more

@staabm
Copy link
Contributor

staabm commented Dec 7, 2013

Check your php.ini for a proper date.timezone key

@brahimrafik
Copy link

I checked and I changed it to CET (time zone by my mac, found it in the system preference ) and I changed the id to 47..but still nothing :/

@staabm
Copy link
Contributor

staabm commented Dec 8, 2013

Here sou can find the list of supported timezones by php
http://www.php.net/manual/en/timezones.php

Which is did you change to 47?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants