Get the 0-value timestamp date with Carbon
Asked Answered
I

1

5

I am attempting to get the 0-value timestamp in an PHP API. I am currently using Carbon in a Laravel / Dingo API based system.

Is there a simple way to get the 0-value timestamp (presumably something like 01/01/1970) without hardcoding the date?

Intransigence answered 27/4, 2017 at 8:17 Comment(4)
The earliest date? Or the 0-value timestamp?Pummel
Apologies for the ambiguity, I was referring to the earliest 'computer' date, so the 0-value timestamp. I'll change my answer to reflect this :)Intransigence
timestamps can also be negative, giving you dates earlier than 1st January 1970... the baseline date/time for unix timestamps is 1/1/1970 00:00:00 GMT/UTC (note that it is timezoned)Pummel
Ah, I see. That's quite useful, actually.Intransigence
T
17

You could try:

echo Carbon::createFromTimestamp(0)->toDateString();
// Displays: 1970-01-01

So you do not have to hardcode the date, just use a 0 timestamp.

Trela answered 27/4, 2017 at 8:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.