Is there a more efficient or elgant way to get a DateTime object from a relative string?

1 day ago 2
ARTICLE AD BOX

I need two DateTime objects to pass to a method. I'm not all that familiar with the class. After some head scratching and web searching, I have a working solution, but I don't like it.

Currently, I'm using strtotime inside a date call inside a new \DateTime call.

<?php // code $firstfriday = new \DateTime(date('d-m-Y',strtotime('first Friday of March '.$theYear))); $firstsaturday = new \DateTime(date('d-m-Y',strtotime('first Saturday of March '.$theYear))); // more code

This works, but it feels clumsy. Is there a better way to do this? Please educate me.

Read Entire Article