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

1// 2021-10-12 21:48:07.0
2DateTime::createFromFormat('Y-m-d', '2021-10-12');
3 
4// 2021-10-12 00:00:00.0
5DateTime::createFromFormat('!Y-m-d', '2021-10-12');
6 
72021-10-12 21:00:00.0
8DateTime::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:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord