[wp-trac] [WordPress Trac] #48976: Current_time
WordPress Trac
noreply at wordpress.org
Mon Dec 16 11:56:04 UTC 2019
#48976: Current_time
-------------------------------+------------------------------
Reporter: autotutorial | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Date/Time | Version: 5.3
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Comment (by Rarst):
> but keep in mind that the hour is a float and not int as it does
current_time but especially for the timestamp does not take into account
the timezone string, if the timezone string is present the quasi numerical
offset has a value of 0
Sorry, I don't follow this.
Could you maybe provide a code example of what you are trying to do and
what happens instead of what you expect?
> With php 7.3 I get an error if the DateTimeZone is not an object but a
string
Could you please provide example that causes the error and what your time
zone settings are?
> it is useful to check the DateTimeZone string with the WordPress string,
differently when working dynamically with the php database timezone table
( there should not be a timezone conversion) also previous versions use
daylight saving time incorrectly
I don't follow this part. Yes, historically there are a lot of DST bug
caused by use of WP timestamps (sum of a Unix timestamp with time zone
offset). Historically WP calculated these by adding offset at ''current''
time, which might be wrong, but doing this is altogether wrong.
This behavior is preserved for backwards compatibility reasons and optimal
action is to use real Unix timestamps and proper
DateTimeImmutable/DateTimeZone objects.
> Another aspect is if I use php with local settings or the variable tz
who knows how DateTime works?
The point of new API is that DateTimeZone works regardless of underlying
settings.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48976#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list