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 4000800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:49:35+00:00 2026-05-20T07:49:35+00:00

I have a date stored in a database in this format: 2011-02-23 13:00:00 I

  • 0

I have a date stored in a database in this format:

2011-02-23 13:00:00

I need to return it in ISO8601 format, but it needs to be set to a specific time zone (which is not necessarily the time zone of the server.) What I want to return is this:

2011-02-23T13:00:00-0600

Using this code:

echo date(DATE_ISO8601, strtotime("2011-02-23 13:00:00"));

I get this:

2011-02-23T13:00:00+0000

Is there any way to reset the time zone in the date or strtotime function, or do I need to strip off the 5 rightmost characters and concatenate the desired timezone stamp to the remaining date/time?

EDITED TO ADD:
Although I did accept the solution below of using new DateTime and setting new DateTimeZone, I found an easier way if you don’t need to keep resetting the time zone:

date_default_timezone_set('America/Chicago');
$startTime = date(DATE_ISO8601, strtotime("2011-02-23 13:00:00"));
  • 1 1 Answer
  • 1 View
  • 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-05-20T07:49:36+00:00Added an answer on May 20, 2026 at 7:49 am

    You could use the DateTime class. Datetime objects can be initialized with a specific time zone, and easily transposed to others.

    Modified from the manual:

    $date = new DateTime('2011-02-23 13:00:00', new DateTimeZone('Pacific/Nauru'));
    echo $date->format('c') . "\n";
    
    $date->setTimezone( new DateTimeZone('Europe/Berlin'));
    echo $date->format('c') . "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a (date time) stored in database in this format 2011-10-12 02:01:24 when
I have a database that a time filed that is stored in this format
I have a date stored in a MySWL database in the following format. 2011-08-23
I have a database field where date is stored as DD/MM/YYYY format. Now what
I have data stored as below in an MS Access database: Date User 20090101
I have a table in sql where the date format is stored in Hijri.
I have a MySQL database with a date_of_birth field. The data stored in this
I have converted date to my local time as below: $this->date_string = %Y/%m/%d %h:%i:%s;
I have Date objects stored in database. Now am when the form I am
I'm working with an MS-SQL database with tables that use a customized date/time format

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.