Veripex, Inc. wrote: >DateTime::now() does not appear to be accurate for me. I used to methods to >prove this. The first method is creating a DateTime object using information >provided by localtime(). The second is using the DateTime::now() method. The >localtime method provides what I expected, the DateTime::now() method has an >incorrect hour for me.
A DateTime object doesn't just represent a date and time of day, it also has an attached timezone. With DateTime->new you're giving it a date and time in your local timezone and not specifying a timezone, so it only knows the local time and that's all it can show you. DateTime->now, on the other hand, picks up the correct absolute time, but because you didn't specify a timezone it doesn't know how you want it displayed. It defaults to using the UTC timezone, and the hour that it shows you is the current UTC hour. You can see these timezone settings in your dumps of the DateTime objects. Neither of these timezone settings is what you want. You most likely want to use your local timezone in both cases. Try adding the parameters "time_zone => 'local'" in both constructor calls. -zefram
