0

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??

1
Contributor
1
Reply
10
Views
1 Year
Discussion Span
Last Post by James_43
2

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

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.