0

I have tried this:

date_default_timezone_set('America/Los_Angeles');
echo $starttime =   date("m/d/Y H:i:s");
echo $endtime   =   date("m/d/Y H:i:s", strtotime('+3 hours', strtotime($startdate)));

// Output    
06/14/2014 04:23:25
06/14/2014 07:23:25

// It should be
06/14/2014 01:23:25
06/14/2014 04:23:25

but it shows +3 hours from PDT time. I have read Pacific Time Zones here but I'm still unable to show time according to PDT.

One approach could be to subtract 3 hours from the time but isn't there any way to do it like this:

date_default_timezone_set('<PDT_Time>');
Adil Abbas
  • 63
  • 2
  • 9
  • 1
    Show the code you're using to print a date, and what the output is that looks wrong. America/Los_Angeles should give the correct results. – Dave Morrissey Jun 14 '14 at 08:16
  • @DaveMorrissey Bingo! Show us the code that is not working in conjunction with `date_default_timezone_set`. – Giacomo1968 Jun 14 '14 at 08:17
  • Add e, P or T (or all three) to your date format to check the dates are in the correct zone. Also check your system clock, it may be wrong. – Dave Morrissey Jun 14 '14 at 09:08
  • By using "e P T", America/New_York -04:00 EDT is shown with the date, still unable to show PDT. IMHO, subtracting 3 hours would just do fine. – Adil Abbas Jun 14 '14 at 10:48
  • What version of PHP are you running? You need PHP 5.1.2 or above for this to work. – Matt Johnson-Pint Jun 15 '14 at 17:50
  • possible duplicate of [php - date\_default\_timezone\_set not working, but ini\_set 'date.timezone' does. Why?](http://stackoverflow.com/questions/15096297/php-date-default-timezone-set-not-working-but-ini-set-date-timezone-does-w) – Matt Johnson-Pint Jun 15 '14 at 17:51
  • @Matt Currently, it is 5.3.9. – Adil Abbas Jun 16 '14 at 05:46

0 Answers0