Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Execute Php Script In Different Time Zone Than Server Time Zone

server time zone

  • Please log in to reply
2 replies to this topic

#1 Jimbow

Jimbow

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 15 May 2012 - 03:01 AM

Hi
I've a script written in PHP that get the time using localtime() function, then do somethings after that.
this script should runs on top of each hour in Asia/Tehran time zone, but the server that script runs on it placed in Dallas and CDT time zone. result, when it's 2:00 in Iran and I want the script got executed the time on server is 4:30, and when the server time is 5:00 the time in Iran is 3:30 thus the crontab is useless.
Any idea about this?

+ I haven't root access on server for change the timezone
+ Sorry for poor English
  • 0

#2 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 15 May 2012 - 08:17 AM

Have you mistyped, or is it really 1,5 hour difference in Iran compared to 0,5 hour in Dallas? I don't think so. Calculate by time difference at what dallas time you want it to run, and you can use cron without a problem.

CDT indicates daylight saving time, which means that if you checked right the night dallas started its dst, the diff can be explained.
  • 1

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#3 Jimbow

Jimbow

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 15 May 2012 - 09:31 AM

Thanks Orjan.
I want to do something when it's on top of each hour in Iran/Tehran, for example when it's 10:00 in Iran(+330GMT) the Dallas(-500GMT) is 12:30. so I resolve the problem with this solution:
-----
placed an IF in script that checks for minutes of timepiece (00:30) in Dallas and it's top of hour in Iran!
cron execute the script every minute, it's working

+ Sorry for poor English
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download