简体   繁体   中英

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?

strtotime() can generate date date from almost any line of text. strtotime('April 13') is okay for April 13 in current year. 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(0, 0, 0, 4, 13); // 0:00:00, 4th month, 13 day, [current year].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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