field created with the Date module (Year, Month, Day, Hou">

Change Date field into GMT by Country Code with "Execute custom PHP code"

by cristtiano   Last Updated September 26, 2018 17:07 PM

I have in Drupal 7 the created content type called "GMT Time" with the fields:

"Time" (field_time) -> field created with the Date module (Year, Month, Day, Hour(24hour format), Minute)

"GMT Time" (field_gmt_time) -> field created with the Date module (Year, Month, Day, Hour (24hour format), Minute)

"Country Code" (field_country_code) -> created as text field

Is it possible to create a "Execute custom PHP code" rule in Rules module which would recalculate the selected time from the field_time into the GMT time into the field_gmt_time by the manualy entered field_country_code which would be in 2 letter format such as "US"? The rule would be created to trigger before saving content type.

And is it possible to also include the Daylight Saving Time and British Summer Time correction by the field_country_code?

Maybe somehow with help of the functions "new DateTime" and "DateTimeZone"? Maybe beginning with

$timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $node->field_country_code[LANGUAGE_NONE][0]['value']);

?

Many thanks for help.

Tags : rules datetime


Related Questions



Recurring date events as entities?

Updated March 31, 2017 08:07 AM



Set a Date field with Rules?

Updated March 27, 2017 17:07 PM