开发者

to string format in strftime()

开发者 https://www.devze.com 2023-03-21 00:49 出处:网络
how to make strftime return as string and not as flot/integer/doub开发者_运维百科le if the timestamp is today (7-17-2011)

how to make strftime return as string and not as flot/integer/doub开发者_运维百科le

if the timestamp is today (7-17-2011)

Then this

strftime('%m %d', $time);

... will return 07 17

But if you remove the space in strftime like this

strftime('%m%d', $time);

... it will return 717

How can you format the output to a string so the returned var will be 0717?


i've just tested it with

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

And it works. But if you interpret the result as a number, then you obtain 717 since initial 0 are not significative. You must keep it as string.

It does not happen with %m %d likely since the space avoid the possibility of interpreting the whole result as a number.

0

精彩评论

暂无评论...
验证码 换一张
取 消