简体   繁体   English

如何从 PHP 中的 mm-dd-yyyy 格式中删除前导零?

[英]How would I remove leading zeros from this mm-dd-yyyy format in PHP?

What would I change to make this format without leading zeros?我会改变什么来使这种格式没有前导零? I know it is simple but have not worked with PHP in some time.我知道这很简单,但有一段时间没有使用 PHP。

$ts = strtotime($product['releaseDate']);
$release_date_formatted = date('m-d-Y', $ts);

Release Date
03-01-2020 --> 3-1-2020
08-15-2020 --> 8-15-2020
04-09-2018 --> 4-9-2020
date('n-d-Y')

Check out this document , which contains a detailed description:查看此文档,其中包含详细说明:

"n" stand for: Numeric representation of a month, without leading zeros. “n”代表:月份的数字表示,没有前导零。

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

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