繁体   English   中英

strftime 给我返回空字符串

[英]strftime returns me empty string

我有一个非常简单的错误,我不明白为什么stftime PHP function返回一个空字符串,而语法和代码似乎都正确。

我得到以下代码:

$next_high_tide_date = strtotime($next_high_tide_date);
// FROM '2021-05-22 00:26:00' TO (timestamp) 1621635960
$next_high_tide_date_day = strtoupper(strftime('%A %d %B', $next_high_tide_date));
// THIS RETURNS ME THE RIGHT DAY DATE
$next_high_tide_date_hour = strtoupper(strftime('%k H %M', $next_high_tide_date));
// THIS RETURNS ME AN EMPTY STRING

第一次声明后我的$next_hight_tide_date值等于1621643160 (时间戳)。 我在网上检查了 strftime 检查器,我的代码是正确的,但在我的 php 页面中,仍然返回一个空字符串。

有人有想法吗?

捕获我的代码

也许你应该使用date() function 来格式化你的时间戳。

$next_high_tide_date = "2021-05-22 00:26:00";
$next_high_tide_date = strtotime($next_high_tide_date);
$next_high_tide_date_day = strtoupper(date('l d F', $next_high_tide_date));
$next_high_tide_date_hour = strtoupper(date('H \H i', $next_high_tide_date));

尝试这个

或使用%H而不是%k

$next_high_tide_date = "2021-05-22 00:26:00";
$next_high_tide_date = strtotime($next_high_tide_date);
$next_high_tide_date_day = strtoupper(strftime('%A %d %B',$next_high_tide_date));
$next_high_tide_date_hour = strtoupper(strftime('%H H %M',$next_high_tide_date));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM