php 如何从日期和月份中删除第一个数字 0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8870813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to delete firstdigit 0 from date and month
提问by 966p
Code:
代码:
$today_mem = date("d.m");
echo $today_mem; // -> 15.02
I need to transform dates like 15.02 into 15.2, also need to transform for ex. 07.02 into 7.2 and so on every day. So the question is: how to delete firstdigit 0 from date and month. Any short solutions?
我需要将 15.02 之类的日期转换为 15.2,也需要转换为 ex。每天 07.02 变成 7.2 等等。所以问题是:如何从日期和月份中删除第一个数字 0。任何简短的解决方案?
回答by chrisn
You'll want to use:
你会想要使用:
$today_mem = date("j.n");
echo $today_mem; // -> 15.2
To remove the leading zeros. See more format modifiers at: php.net/date
删除前导零。在以下位置查看更多格式修饰符:php.net/date