I tried to find more info about why the date_i18n() would not be a working solution anymore. Can you give me some information or documentation about that? All I found is that the date_i18n function is still a valid wrapper for the new wp_Date function.
And can you give me a valid example on a place where you have a wrong displayed date so I can try to reproduce the issue? I don’t see any column in our codebase that uses the date_i18n function.
Thread Starter
Duke
(@dukessa)
If you read the docu for wp_date() it clearly states:
This is a newer function, intended to replace date_i18n()
Also, see the issues also ACF had here:
https://support.advancedcustomfields.com/forums/topic/time-field-and-wp-5-3/
I understand that it will be a replacement for the old method, but nothing states that the date_i18n method is obsolete. What I read is that date_i18n could give strange results when some plugins wrongly use the date_default_timezone_set method.
So sure, I believe that moving to wp_date() is definitely something that must be done in our plugin in the (near) future. But since we still have customers on WordPress < 5.3, for us it’s a bit early to create a dependency on WordPress 5.3 for such a minor (my opinion) improvement.
I don’t see the wp_date() method yet in the ACF plugin either.
Maybe if you can tell me where you really have issues with the used date format, I can at least find a workaround for you until we change this in our code.
Thread Starter
Duke
(@dukessa)
How dates are saved in the post (please mind the Data Fine one, starting at 00:00):

How Admin Columns is set:

Where it goes wrong (in the post admin list, Data Fine is brought back 1h, so it shows like it’s starting the day before):

ACF has already notified users of how to fix it and will release it to all in the next update (talked to support). Their fix works fine everywhere, so now it’s just Admin Columns not working. Considering users will be upgrading to 5.3 the more and more, I think it would be safer for you to allow for date_i18n as legacy for < 5.3 and wp_date for >= 5.3 π
Just to be sure, what is the actual value in the database for date_fine?
I don’t really see what plugin you use to store those values, and I want to know the exact values in your database in order to see what we can do. I’m trying to reproduce this on my local environment with the following code:
$date = '2019-03-01 00:00:00';
echo date_i18n( 'Y-m-d H:i:s', strtotime( $date ) );
But the outcode is the same.
Thread Starter
Duke
(@dukessa)

There you go π As you can see, issue is very much there.
The date in DB is saved correctly.
Also, re-read the ACF thread I posted, it happens to a lot of people, since WP 5.3 (and ACF fixed it using wp_date())
Hi,
FYI, more info about this can be found at the Make WordPress Core blog.
Guido
This thread helped resolved my issue of Time displaying different to my timezone settings after a whole day debugging.
Thanks @guido07111975, My issue was related to the comment “donβt change PHP time zone with date_default_timezone_set() (this one is hard requirement for correct core operation!)” in your link.
-
This reply was modified 6 years ago by
dalingzaf.
PHP date and wp_date give different values it seems because WordPress set time zone independently from PHP. I learned this, after discovering than date function in a logging plugin function was always two hours wrong. So, if you want to use WordPress time you may use wp_date with proper parameters.
It follows php that function date follows from php settings that can be different from WP settings
Also, I learned (too late) that is not possible to use date_default_timezone_set in wordpress plugins. See reference (https://make.ww.wp.xz.cn/core/2019/09/23/date-time-improvements-wp-5-3/)
-
This reply was modified 5 years, 10 months ago by
capbussat.
-
This reply was modified 5 years, 10 months ago by
capbussat.