Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts

    Question Managing timezones for different users

    Hi

    I have a website where I have many users coming from different countries. Users can schedule a task based on their timezone. Now there is a cron running on the server after every min, the cron executes a script which checks if there are any scheduled task of any user and if so it does the needful.

    Since my server is based in the US, the script executed by the cron considers the timezone of the US. What do I have to do in my script that will execute the user's task based on user's timezone instead of server's timezone?

    Thanks in advance for any ideas

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Hi cancer10,

    When your users signup or create a task, make sure you ask them for their timezone, and save it in database.. then in your CRON triggered PHP script just set the user's timezone when the script runs... at the top of the script:

    PHP Code:
    date_default_timezone_set("Europe/Berlin"); 
    Here is a list of all the supported time zones http://php.net/manual/en/timezones.php

    Cheers,

  • #3
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts
    Thanks for your reply

    is there any function in php that will tell me the time difference between the server timezone and the user's timezone?

    For example how much difference in hours is US timezone and Japan timezone?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •