Always get really confused when dealing with timezones...

I have a string 8/11/2013, which I apply the following code:

    $firstDate = new DateTime($rawData[$backdate][0]);
    $firstDate = $firstDate->format('d/m/Y');

The issue is that PHP seems to think that the '11' is the day, when it's actually the month (I'm in NZ). When I print_r the DateTime Object, it recognises that the object is in NZ timezone... is this what is causing the problem, since the original string is in US date format??

Found out you can specify a format when creating the object :)

DateTime::createFromFormat('d/m/Y', $date);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.