Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Gregorian date (in seconds) to unix timestamp in PHP

I have a webservice returning timestamps in Gregorian seconds.

How do I convert Gregorian date (in seconds) to unix timestamp in PHP?

like image 942
lilbiscuit Avatar asked Aug 08 '13 01:08

lilbiscuit


People also ask

How can I timestamp in PHP?

The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.

Is Unix timestamp in seconds or milliseconds?

Unix time is a system for representing a point in time. It is the number of seconds that have elapsed since January 1st, 1970 00:00:00 UTC.

How do I change timestamp to date?

You can simply use the fromtimestamp function from the DateTime module to get a date from a UNIX timestamp. This function takes the timestamp as input and returns the corresponding DateTime object to timestamp.

What is Unix timestamp in PHP?

PHP provides several date-time functions to perform required operations with temporal data. Now, we are going to see about PHP timestamp functions. The timestamp is the value represented as seconds calculated, since UNIX Epoch, January 1, 1970, and also called as UNIX timestamp.


1 Answers

subtract unix epoch(62167219200) from the Gregorian seconds returned by the web service. see here

like image 150
hago Avatar answered Sep 28 '22 08:09

hago