How to use createFromString() in Craft 3 In Craft 2 I've used createFromString() as following:

DateTime::createFromString($pubDate, craft()-&gt;timezone)


But if I use this function in craft cms 3 then I'm getting the following error:

Call to undefined method DateTime::createFromString()


Is there any alternative way to use the createFromString() in Craft 3?
You're looking for the toDateTime() method in the DateTimeHelper class:

DateTimeHelper::toDateTime($pubDate, true);