Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here

Reset all of the remaining time units

You can insert an exclamation into the DateTime::createFromFormat() method to reset all of the remaining time units

// 2021-10-12 21:48:07.0
DateTime::createFromFormat('Y-m-d', '2021-10-12');
 
// 2021-10-12 00:00:00.0
DateTime::createFromFormat('!Y-m-d', '2021-10-12');
 
// 2021-10-12 21:00:00.0
DateTime::createFromFormat('!Y-m-d H', '2021-10-12');

Tip given by @SteveTheBauman

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 67 courses (1172 lessons, total 43 h 18 min)
  • 90 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent New Courses