[英]strftime returns me empty string
I have a really simple error and I don't get why stftime PHP function returns me an empty string while all seems right with the syntax and code.我有一个非常简单的错误,我不明白为什么stftime PHP function返回一个空字符串,而语法和代码似乎都正确。
I got the following code:我得到以下代码:
$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
My $next_hight_tide_date
value after the first declaration is equal to 1621643160
(timestamp).第一次声明后我的
$next_hight_tide_date
值等于1621643160
(时间戳)。 I checked on a strftime checker online and my code is right, but in my php page, still returns me a empty string.我在网上检查了 strftime 检查器,我的代码是正确的,但在我的 php 页面中,仍然返回一个空字符串。
Anyone has an idea?有人有想法吗?
Maybe you should use the date()
function to format your timestamp.也许你应该使用
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));
try this尝试这个
or use %H
instead of %k
或使用
%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.