Re: trouble trying to display google timestamp with php

From: Date: Mon, 14 Mar 2016 23:08:56 +0000
Subject: Re: trouble trying to display google timestamp with php
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-325469@lists.php.net to get a copy of this message
On Mon, Mar 14, 2016 at 7:02 PM, dealtek@gmail.com <dealtek@gmail.com> wrote: > Hi all, > > I am getting a timestamp from google maps. when I display it in javascript > it works but gives odd results when I try with php... Maybe there is > something different with the google timestamp? > > > regular ts: > 1457995288 > > google ts: > 1457914808793 is longer > > > Q: What is different about the google timestamp and how can I display it > with php? > > > ------------------------ > > > date_default_timezone_set("America/Los_Angeles"); > > ---- this works fine (regular ts) > > $date = date_create(); > date_timestamp_set($date, 1457995288); > echo date_format($date,"Y/m/d H:i:s"); > > --- it shows ok = 2016/03/14 15:41:28 > > > ------------ > > OK but does not work with google map timestamp (LONGER): > > $date2 = date_create(); > date_timestamp_set($date2, 1457914808793); > echo date_format($date2,"Y/m/d H:i:s"); > > -- it shows odd (google longer ts) = 48169/06/24 15:46:33 > > ------------------- > > with javascript this works with google timestamp > > var nowts = new Date(Number(value.timestamp)); > > and shows like = Sun Mar 14 2016 17:20:08 GMT-0700 (PDT) > > > -- > Thanks, > Dave - DealTek > dealtek@gmail.com > [db-16] > > To confirm my assumption, I did a google search "javascript timestamp to php timestamp" and it was correct, the timestamp coming from javascript is the micro timestamp and in PHP you are using regular timestamp. Micro timestamp is more to the dot than a regular timestamp.

« previous php.general (#325469) next »