Skip Navigation

[Résolu] types_render_field return date on day before what it's set in the post

This support ticket is created Il y a 7 années et 7 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 réponses, has 2 voix.

Last updated by marc-andre Il y a 7 années et 7 mois.

Assisted by: Minesh.

Auteur
Publications
#430890

ok the problem see to be a timezone problem... but let's start at the begining...
in the post, i select the date : sept 17 2016

so now when i retreive the date, i what it formated in french so
i use this function : $date_converted = types_render_field( "date_mam", array( "format" => "l j F Y", "output" => "html"));

and now the $date_converted = vendredi 16 septembre 2016

why one DAY BEFORE the real date ?????

#431126

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

1)
I would like to know is there any timezone set from your theme or any other plugin?

2)
Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

3)
Where you used to save date field with Types CPT?

#431458

i have removed this :

date_default_timezone_set('America/Montreal');
setlocale(LC_ALL, 'fr_CA');

the timezone in WP is newyork (the same as montreal), and the above timezone setting SHOULD work.... i dont know why withou them it work....

any idea ?

#431781

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

The date field is stored as a timestamp, so the rendering value depends on the timezone you have set or rather server is in.

The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT) . That means that the timestamp is fixed based on a fixed timezone. But what a timestamp means on a given timezone changes, and that is what gets output.

For example:
The timestamp on Spain refers to a number of seconds from Jan 1 1970 00:00 UTC, and that same value, when you move to Australia, gives a different moment of the day, even a different day.

Also, it does not depend so much on what time you think you are in, but what time/timezone the server is setup.

So, please check both your server timezone setup as you said it works when you remove the timezone settings that means server is setup into different timezone.

#434563

make sens, thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.