Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在strftime()中设置字符串格式的步骤_Php - Fatal编程技术网

Php 在strftime()中设置字符串格式的步骤

Php 在strftime()中设置字符串格式的步骤,php,Php,如何使strftime返回为string而不是flot/integer/double 如果时间戳是今天(7-17-2011) 那么这个 strftime('%m %d', $time); 。。。将返回07 17 但是如果像这样移除strftime中的空间 strftime('%m%d', $time); 。。。它将返回717 如何将输出格式化为字符串,以便返回的变量为0717?我刚刚用 <?php echo strftime('%m%d', time()); ?> 它是有效

如何使strftime返回为string而不是flot/integer/double

如果时间戳是今天(7-17-2011)

那么这个

strftime('%m %d', $time);
。。。将返回
07 17

但是如果像这样移除strftime中的空间

strftime('%m%d', $time);
。。。它将返回
717


如何将输出格式化为字符串,以便返回的变量为
0717

我刚刚用

<?php
echo strftime('%m%d', time());
?>

它是有效的。但是如果你把结果解释为一个数字,那么你会得到717,因为最初的0是没有意义的。你必须把它当作绳子


%m%d
可能不会发生这种情况,因为空格避免了将整个结果解释为数字的可能性。

使用
echo strftime(“%m%d',time())对其进行了测试并按预期工作。你有哪个版本的php?可能是旧的吗?您使用的代码在哪里?--哦,没有启发:你把结果解释为一个数字!