2

I am using Date module with date popup . And I am creating these node pro grammatically and saving dates to them like:

$node->field_task_time[LANGUAGE_NONE][0]['value'] = "2014-12-18 23:15:00";
$node->field_task_time[LANGUAGE_NONE][0]['timezone'] = "Asia/Kolkata";
$node->field_task_time[LANGUAGE_NONE][0]['timezone_db'] = "UTC/GMT";
$node->field_task_time[LANGUAGE_NONE][0]['date_type'] = "datetime";

The values in db are stored correctly but when I edit this node form the values in the date field shows 2014/12/18 and in time field it shows 4:15. i Don't know what's happening .

2

It seems as default behavior of date module if you check its documentation you can see:

Time zone handling

There are 5 different options for field Time zone handling:

Site's time zone - When entering data into the field, the data entered is assumed to be in the site's time zone. When the data is saved to the database, it is converted to UTC. When retrieved from the database, the data is converted to the Site's time zone for anonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.

Date's time zone - With this option enabled, the date field adds a select box to explicitly specify the time zone for the date entered. When the date is saved to the database, it is not converted & the time zone information is saved with the date. When retrieved from the database, no conversion is performed and the date is displayed exactly as entered.

User's time zone - When entering data into the field, the data entered is assumed to be in the user's time zone. When the data is saved to the database, it is converted to UTC. When retrieved from the database, the data is converted to the Site's time zone for anonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.

UTC - When entering data into the field, the data entered is assumed to be in UTC time zone. When the data is saved to the database, it is converted to UTC (e.g. no conversion necessary). When retrieved from the database, the data is converted to the Site's time zone for anonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.

No time zone conversion - The date entered is not converted when saved to the database. When retrieved from the database, the data is NOT converted and is displayed exactly as entered.

so currently your settings are in site's timezone which is assuming that you entered date is in UTC hence the retrieved date is site's timezone which is UTC+5:30 switch setting s to No time zone conversion and you can see retrieved date as entered one.

  • 1
    I have solved the issue, The problem was in managed field I have selected site's timezome and saving the data in utc format. As soon as I changed this to utc the problem has gone away. – harsh_behl_0007 Dec 4 '14 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.