Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Getting a client and server to agree on UTC time



> Here's the code I use to get the UTC time on the PHP side.
> $utcTime = time() - date("Z");

Because of the User Contributed Notes the PHP manual is a beautiful
creature. Check the most recent note on this page:
 http://php.net/manual/en/function.time.php

The first example is exactly what you want:
  date_default_timezone_set("UTC");
  echo "UTC:".time();

(The comment says UTC is the default, but ignore that, as the default
actually comes from any of the TZ environment variable, the
date.timezone ini option or some query of the OS.)

More explanation here:
  http://php.net/manual/en/function.date-default-timezone-get.php
  http://php.net/manual/en/function.date-default-timezone-set.php

HTH,
Darren



-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/gobet/  (Shodan Go Bet - who will win?)
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links