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

  • Home
  • SEARCH
  • 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 8624229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:28:22+00:00 2026-06-12T07:28:22+00:00

Using PHP 5.3 and given the string Sat, 20 Oct 2012 05:00:00 GMT :

  • 0

Using PHP 5.3 and given the string Sat, 20 Oct 2012 05:00:00 GMT:

print $start;
$start = strtotime($start);
var_dump($start);
$hour = date('H:i A', $start);
die($hour);

That snippet of code in my program returns this:

Sat, 20 Oct 2012 05:00:00 GMT
int(1350709200)
00:00 AM

The var_dump is correct, but the date returns a bad answer.

Note, also, that changing that snippet to read:

print $start;
$start = strtotime($start);
die($start);
$hour = date('H:i A', $start);
die($hour);

returns:

Sat, 20 Oct 2012 05:00:00 GMT

The first die returns an empty string, a null, which I can only assume is actually a boolean FALSE.

So I’m actually having two different problems, here. The same answer returns two different things depending on if I var_dump or die, and the second is that date appears to be receiving the FALSE answer, not the var_dump answer.

Help?

  • 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-12T07:28:23+00:00Added an answer on June 12, 2026 at 7:28 am

    AS you have said, you are setting the timezone to America/Chicago. When you call strtotime you are explicitly specifying GMT in the string. When you then put the timestamp into Date, it is taking the timestamp and giving you the time in America/Chicago, 5 hours before GMT, which is why it is 00:00AM.

    You are using 5.3. I would suggest using the DateTime object instead of strtotime() and date(). Its a bit easier to work with timezones etc, and the var_dumps are useful. Create a DateTime from user input or db value and then pass that around in your code instead of timestamps.

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

Sidebar

Related Questions

I am using PHP & want to parse given string: Let say $str =
Using PHP, given a string such as: this is a <strong>string</strong> ; I need
I need to upload a given image using Amazon S3 I have this PHP:
I am trying to create an md5 value in php using the instruction given.
I have a php parser that split a given string by line-breaks, doing something
Using PHP, given a URL, how can I determine whether it is an image?
Using ASP.NET, how can I strip the HTML tags from a given string reliably
Possible Duplicate: In PHP given a month string such as “November” how can I
I'm using the 'e' modifier in preg_replace to search for a given string. Then
Possible Duplicate: In PHP given a month string such as “November” how can I

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.