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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:26:09+00:00 2026-05-17T00:26:09+00:00

I have the following piece of code. I’ve recorded the output as well: function

  • 0

I have the following piece of code. I’ve recorded the output as well:

function convertGeneralAvailabilityTime($date,$from_timezone,$from_timebegin, $from_time$
{
echo "$date,$from_timezone,$from_timebegin, $from_timeend, $to_timezone"; 
// 2010-09-19,America/New_York,07:45:00, 08:00:00, America/Los_Angeles

$tz1 = new DateTimezone($from_timezone);

$datetime1 = new DateTime("$date $from_timebegin", $tz1);
$datetime2 = new DateTime("$date $from_timeend", $tz1);

echo "$date $from_timebegin";
// 2010-09-19 07:45:00
echo "$date $from_timeend";
// 2010-09-19 08:00:00
var_export($tz1);
//DateTimeZone::__set_state(array(
//))
var_export($datetime1);
//DateTime::__set_state(array(
//))

SOmething is wrong with my php’s DateTime() funciton – but I cannot fathom what! I’m using PHP 5.2.14 on this server.


Edit 1: Sorry, misinterpreted some PHP output – corrected it above


Edit 2: I had the following test file which gave the exactly output as below

<?php
$date = '2010-09-19';
$from_timezone = 'America/New_York';
$from_timebegin = '07:45:00';
$from_timeend = '08:00:00';
$to_timezone = 'America/Los_Angeles'; // Trimmed 2010-09-19 07:45:002010-09-19

$tz1 = new DateTimezone($from_timezone);

$datetime1 = new DateTime("$date $from_timebegin", $tz1);
$datetime2 = new DateTime("$date $from_timeend", $tz1);

echo "$date $from_timebegin".PHP_EOL;
echo "$date $from_timeend".PHP_EOL;
var_dump($tz1);
var_dump($datetime1);

?>

Output:

jailshell-3.2$ php dttest.php
2010-09-19 07:45:00
2010-09-19 08:00:00
object(DateTimeZone)#1 (0) {
}
object(DateTime)#2 (0) {
}

Edit 3 – if it helps, my phpinfo shows this as well

date
date/time support   enabled
"Olson" Timezone Database Version   2010.12
Timezone Database   external
Default timezone    America/Chicago 
  • 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-05-17T00:26:09+00:00Added an answer on May 17, 2026 at 12:26 am

    I simplified and ran your code. This is the output:

    php > $date = '2010-09-19';
    php > $from_timezone = 'America/New_York';
    php > $from_timebegin = '07:45:00';
    php > $from_timeend = '08:00:00';
    php > $to_timezone = 'America/Los_Angeles'; // Trimmed 2010-09-19 07:45:002010-09-19 08:00:00
    php > 
    php > $tz1 = new DateTimezone($from_timezone);
    php > 
    php > $datetime1 = new DateTime("$date $from_timebegin", $tz1);
    php > $datetime2 = new DateTime("$date $from_timeend", $tz1);
    php > 
    php > echo "$date $from_timebegin".PHP_EOL;
    2010-09-19 07:45:00
    php > echo "$date $from_timeend".PHP_EOL;
    2010-09-19 08:00:00
    php > var_dump($tz1);
    object(DateTimeZone)#1 (0) {
    }
    php > var_dump($datetime1);
    object(DateTime)#2 (3) {
      ["date"]=>
      string(19) "2010-09-19 07:45:00"
      ["timezone_type"]=>
      int(3)
      ["timezone"]=>
      string(16) "America/New_York"
    }
    

    I don’t see a problem.

    Your echo at the top contains junk at the end (after the timezone)

    echo "$date,
          $from_timezone,
          $from_timebegin, 
          $from_timeend, 
          $to_timezone"
    ;
    
    // 2010-09-19,
    // America/New_York,
    // 07:45:00, 
    // 08:00:00, 
    // America/Los_Angeles2010-09-19 07:45:002010-09-19 08:00:00
    

    What’s all the extra stuff at the end?

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

Sidebar

Related Questions

I have the following piece of JS code within a function that responds to
I have the following piece of JS code within a function that responds to
I have the following piece of code in my Spring MVC application: @RequestMapping(value =
I have the following piece of code in a file that I opened in
Hello I have the following piece of code and it won't post the data
Right now I have the following piece of code: RSpec::Matchers.define :include_an_html_tag do |tag| tag
I have a problem updating a value of a variable in a shell script
I have to create a page scope COM object in ASP for WIN CE
I am getting a memcpy is not defined in this scope error with the
I recently came to know the concept of 'connection pooling' in .NET, and as

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.