I'm trying to get the drupal time (Date and Time) to be set to Asian/Tehran but no luck.

My configurations is:
- installed the Calander Systems 6.x-1.50
- installed the Date module 6.x-2.7 ( http://drupal.org/project/date )

The calendar system has turned my calendar to Farsi/Persian just fine but then I installed the Date module just to ensure I can set exact timezone to Asian/Tehran;
It seems that the Date module has done its job okay and the Tehran time is showing, when I'm at the Time and Date looking at the format ( admin/settings/date-time/formats ) I see the time to be correct and shoiwing Tehran's time;
however, when I post some content (using create Content), after the content is posted, the time of the content post is shown incorrectly.

ie. say if the correct Tehran's time is 19:04 :
Time and Date Formats ( admin/settings/date-time/formats ) shows correctly: 19:04
but when posting any content the time of the post is shown incorrectly 8:04 instead of 19:04

Ps. It's only an issue with the TIME not the date. the date is whoing correctly.

I'm quite clueless as what is causing this, if you could kindly enlighten me with any hints, that would be great, ...?
thanks

Comments

ah0’s picture

any pointers at all?
Thanks

farshid’s picture

try this:

calendar_systems/calendar/v1/calendarV1.class.inc.php arround Line: 159 find:

$r=date($format, $timestamp);

and change it to:

$r=gmdate($format, $timestamp);

this solved my problem... let me know if it works for you too.

sourcesoft’s picture

Priority: Normal » Critical

just faced to this problem today.
around line 159 you referred to there's a function called phpDate using gmmaketime()

    function phpDate($format, $timestamp=null) {
		if (is_null($timestamp) or empty($timestamp)) {
			if (!empty($this->_timeZoneInfo)) {
				$timestamp=gmmktime()+$this->_timeZoneInfo['offset'];
				$r=gmdate($format, $timestamp);
			} else {
				$timestamp=mktime();
				$r=date($format, $timestamp);
			}
		} else {
			$r=date($format, $timestamp);
		}
		return $r;
	}

tried to change each date function to the one u mentioned and nothing's changed, after posting or updating a post there's a huge time difference.

needs to be fixed, I'm using 1.50 and time difference is still on

farshid’s picture

Hi

have you set your time zone in: admin/settings/date-time ?

sourcesoft’s picture

yes it's asia/tehran.

ah0’s picture

Thank you so much guys it indeed did work just fine,

As farshid mentioned, just changed the

$r=date($format, $timestamp);

and change it to:

$r=gmdate($format, $timestamp);

so the function becomes:


    function phpDate($format, $timestamp=null) {
		if (is_null($timestamp) or empty($timestamp)) {
			if (!empty($this->_timeZoneInfo)) {
				$timestamp=gmmktime()+$this->_timeZoneInfo['offset'];
				$r=gmdate($format, $timestamp);
			} else {
				$timestamp=mktime();
				$r=gmdate($format, $timestamp);
			}
		} else {
			$r=gmdate($format, $timestamp);
		}
		return $r;
	}

Once again a loads of appreciation,

sourcesoft’s picture

Status: Active » Reviewed & tested by the community

Problem solved for me, seems like I've hacked a little bit before to integrate with "scheduler" module and jalali calendar so scheduler was not using the right time.
Thank you, commit it.

sinasalek’s picture

Thanks guys, will be included in the next minor release

ah0’s picture

Thanks Sina,
Regards,

sinasalek’s picture

Issue tags: +6.x-1.6 roadmap

Adding to the next minor release

sinasalek’s picture

Version: 6.x-1.50 » 6.x-1.x-dev
sinasalek’s picture

Status: Reviewed & tested by the community » Fixed

Fixed, try the latest release , if interested to know how it's been fixed have a look at http://drupalcode.org/project/calendar_systems.git/commit/e722d36

farshid’s picture

Hi Sina

What about daylight savings? it is a while (from the beginning of new year, by the way happy new year :) ) our times are showing incorrectly due to +1 hour daylight saving.

I found that adding this offset to date function in iranian.class.inc.php could solve the problem, may be you prefer to add this in another, more appropriate place in the code:

replace:

$TZhours=0;

with:

$TZhours= date('I', $maket);

calendar_systems/calendar/v1/calendarSystems/iranian.class.inc.php

I do not know if you have this problem... or may be you have fixed it in new releases?
Thanks

sinasalek’s picture

Calendar systems deals with date, there are some solutions but haven't tried them http://drupal.org/project/dst ,http://drupal.org/node/11077
PS : Happy new year to u too

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sinasalek’s picture

Tagged