Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8946469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:31:31+00:00 2026-06-15T12:31:31+00:00

I am working on a calendar application. In this users from different time-zones create/view

  • 0

I am working on a calendar application. In this users from different time-zones create/view events.
I am thinking to follow below method to save event time in UTC and display them in user’s local time. Note: user has their preferred timezone setting.

To save event start time as UTC timestamp:

$timezone = new DateTimeZone( $user_timezone_name );
$utcOffset = $timezone->getOffset( new DateTime( $event_start_time_string_local ) );
$event_start_timestamp_local = maketime( $event_start_time_string_local );
//Now add/subtract $utcOffset to/from $event_start_timestamp_local to get event's start  //time  timestamp in UTC and save this result in DB.

To get event start time in user’s timezone:

date_default_timezone_set( $user_timezone_name );
$eventTimeLocalTime = date("Y-m-d H:i:s", $event_start_timestamp_in_UTC );

Where:

user_timezone_name is user's timezone setting.
event_start_time_string_local is event's start time string in local/civil time.
event_start_timestamp_in_UTC is event's start time timestamp in UTC.

My questions:

  • Whether the PHP APIs used above take care of DST for all regions?
  • The DST time itself changes in different years, how does PHP gets information about this? do we need to upgrade PHP? If so do we need to upgrade all or particular PHP library?

References:
– does-phps-date-default-timezone-set-adjust-to-daylight-saving
– get-timezone-offset-for-a-given-location

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:31:33+00:00Added an answer on June 15, 2026 at 12:31 pm

    You’re way too overcomplicating this. To convert between two timezones using DateTime, do this:

    date_default_timezone_set('Asia/Kolkata'); // YOUR timezone, of the server
    
    $date = new DateTime($input, new DateTimeZone('Asia/Tokyo')); // USER's timezone
    $date->setTimezone(new DateTimeZone('UTC'));
    echo $date->format('Y-m-d H:i:s');
    

    This converts from a user’s local timezone to UTC. To go the other way around, to display the time in the user’s local time, swap the two timezones.

    Yes, PHP takes care of DST. The necessary conversion rules are part of the PHP installation. You can keep them up to date by updating PHP, or by updating the timezonedb.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using below code to get calendar events in my application. It's working
i am working on script which creates events in Google Calendar from data in
I am working on a calendar application that outputs a list of events in
Currently I am working on Calendar Application for iPhone. In this project i have
I'm using jcal2 calendar for choosing date from calender. It working when i'm using
I am working on a form widget for users to enter a time of
I am working on simple application which creates google calendar (under it's own account).
I'm building my first application that requires a calendar. I have it working great
I have been working for some time on an application form for an insurance
I've been trying to get Google's Calendar API working in a PHP web application,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.