For the life of me I can't figure out how to return the current time in PHP correctly. First let me show you the setup.
Server local time is in CST
I am in PST so there is a 2 hour difference. I also put in the htaccess of my server the following statement:
SetEnv TZ Amercia/Los_Angeles
Ok and my PHP statement to pull the current time is
<?php $t = time(); echo(date("D F d Y H:i:s",$t)); ?>
But this code seem to return 8 hours ahead...I can't figure out why?? I want it to return my PST time...
Thanks guys!
The time function returns universal time (UTC). If you want the local time, use localtime.
Use this function in your script.
date_default_timezone_set('America/Los_Angeles');
List of supported timezones
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With