Loading ...
Sorry, an error occurred while loading the content.
 

Help Related to Time Difference

Expand Messages
  • Katiyar
    Hello Experts, My local development Environment is + IIS7 + PHP + MySQL on Windows 7, I am trying to print my age on my site, I was using the follwing code .
    Message 1 of 1 , Dec 7, 2010
      Hello Experts,

      My local development Environment is  + IIS7 + PHP + MySQL on Windows 7, 

      I am trying to print my age on my site,  I was using the follwing code .


      *******************************************************************************
      $curDate= new DateTime("now", new DateTimeZone('Asia/Kolkata'));
      print ( "<p>Pass1" );
      $brthDate= new DateTime("1976-1-16", new DateTimeZone('Asia/Kolkata'));
      print ( "<p>Pass2" );
      var_dump( $curDate ) ;
      print ( "<p>Pass3" );
      var_dump ($brthDate ) ;
                         
      $dura = date_diff($curDate, $brthDate, false );
      print ( "<p>Pass4" );
      var_dump ($dura ) ;
                         
      $myAge = $dura->format("%y year, %m month and %d days");
      print ( "<p>Pass5 " );
      var_dump ( $myAge ) ;

      *******************************************************************************

      when I am doing this on local server (localhost) it works fine, See the output below.

      *******************************************************************************
      Pass1

      Pass2object(DateTime)#1 (3) { ["date"]=> string(19) "2010-12-07 16:27:29" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Asia/Kolkata" }

      Pass3object(DateTime)#2 (3) { ["date"]=> string(19) "1976-01-16 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Asia/Kolkata" }

      Pass4object(DateInterval)#3 (8) { ["y"]=> int(34) ["m"]=> int(10) ["d"]=> int(22) ["h"]=> int(16) ["i"]=> int(27) ["s"]=> int(29) ["invert"]=> int(1) ["days"]=> int(6015) }

      Pass5 string(29) "34 year, 10 month and 22 days" old.
      *******************************************************************************

      But When I upload this file to Xtreem host, ( A free Linux Based Web Hosting Server). i get something weird see the output below.

      *******************************************************************************
      Pass1

      Pass2object(DateTime)#1 (0) { }

      Pass3object(DateTime)#2 (0) { }
      *******************************************************************************

      Does it related to environment some how (windows/Linux) or some thing else.
      Any Idea, what I am doing wrong, any help will be appreciated .

      thanks

      prateek.






    Your message has been successfully submitted and would be delivered to recipients shortly.