使用Carbon获取0值的时间戳记日期 [英] Get the 0-value timestamp date with Carbon

查看:572
本文介绍了使用Carbon获取0值的时间戳记日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在PHP API中获取0值的时间戳.我目前在基于Laravel/Dingo API的系统中使用 Carbon .

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.

是否有一种简单的方法可以在不对日期进行硬编码的情况下获取0值的时间戳(大概类似于01/01/1970)?

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

推荐答案

您可以尝试:

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

因此您不必对日期进行硬编码,只需使用0时间戳即可.

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

这篇关于使用Carbon获取0值的时间戳记日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆