简体   繁体   English

如何生成特定日期,例如 3 月 13 日

[英]How do I generate a specific date such as the 13th of March

I have been using the following code to generate a date.我一直在使用以下代码来生成日期。

$datejoined = strip_tags(date('Y-m-d H:i:s', strtotime("+1 day")));

How would I generate a specific date for April 13th?我如何生成 4 月 13 日的特定日期?

strtotime() can generate date date from almost any line of text. strtotime()可以从几乎任何文本行生成日期日期。 strtotime('April 13') is okay for April 13 in current year. strtotime('April 13')在今年的 4 月 13 日是可以的。 Test it with the following line of code:使用以下代码行对其进行测试:

  print date('Y-m-d H:i:s', strtotime('April 13'));

But personally I would suggest you to use much faster function mktime() :但我个人建议你使用更快的函数mktime()

mktime(0, 0, 0, 4, 13); // 0:00:00, 4th month, 13 day, [current year].

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

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