Php obtains the time zone of the Time Service Server

Source: Internet
Author: User
Php gets reliable and accurate current time (via time server. From: justcoding. iteye. comblog843645 returned field Description: www. nist. Without. cfm $ fpfsockopen (time.nist.gov, 13, $ errno, $ errstr, 90); $ ufcexplode (, fread

Php gets reliable and accurate current time (via time server. From: http://justcoding.iteye.com/blog/843645 return field Description: http://www.nist.gov/pml/p688/grp40/its.cfm no $ fp = fsockopen ('time .nist.gov ', 13, $ errno, $ errstr, 90); $ ufc = explode ('', fread

Php gets reliable and accurate current time (via time server. From: http://justcoding.iteye.com/blog/843645
Returned field Description: http://www.nist.gov/pml/p688/grp40/its.cfm <无>
$ Fp = fsockopen ('time .nist.gov ', 13, $ errno, $ errstr, 90); $ ufc = explode ('', fread ($ fp, date ('y'); $ date = explode ('-', $ ufc [1]); $ processdate = $ date [1]. '-'. $ date [2]. '-'. date ('y '). ''. $ ufc [2]; switch ($ ufc [5]) {case 0: echo 'exact '; break; case 1: echo 'error: 0-5s'; break; case 2: echo 'error:> 5s '; break; default: echo 'hardware error! '; Break;} echo gmttolocal ($ processdate, 8); // China function gmttolocal ($ mydate, $ mydifference) {$ datetime = explode ("", $ mydate ); $ dateexplode = explode ("-", $ datetime [0]); $ timeexplode = explode (":", $ datetime [1]); $ unixdatetime = mktime ($ timeexplode [0] + $ mydifference, $ timeexplode [1], 0, $ dateexplode [0], $ dateexplode [1], $ dateexplode [2]); return date ("m/d/y h: I: s", $ unixdatetime );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.