CDateTimeParser::parse bug?

I found that CDateTimeParser::parse with date and time format return a wrong timestamp (the time resulting is wrong), the strange thing is this happen with old date (about year 1901 to 1930-40) instead with recent date it seems to function.

This is an example: (case A is using the php strtotime function that give a correct result, case B is using CDateTimeParser




      $date = '1933-12-11 10:19:30';


      $a=strtotime($date);

      echo "A--".$a."<br/>"; 

      echo date('Y-m-d H:i:s', $a)."<br/>";


      $b=CDateTimeParser::parse($date, 'yyyy-MM-dd HH:mm:ss');

      echo "B--".$b."<br/>";

      echo date('Y-m-d H:i:s', $b )."<br/>";



This is the result:

A—1137850830

1933-12-11 10:19:30

B—1137854430

1933-12-11 09:19:30

other example:

input date:

$date = ‘1911-02-27 09:15:12’;

result:

A—1856962449

1911-02-27 09:15:12

B—1856965488

1911-02-27 08:24:33

Can someone try if this general bug of the function?

For me the correct dates are returned using your example (after correcting the capitalized $B ):


A---1856943888

1911-02-27 09:15:12

B---1856943888

1911-02-27 09:15:12

Which OS are you using? I try on windows 2003 server (php 5.2.11 Yii 1.0.9) and also on a windows xp server (I don’t have a linux installation to try) could be a windows problem?

(I correct $B to $b )

I am on Windows XP using Apache, PHP 5.2.9-2, Yii 1.1

I think I found where the bug originate, the problem is in the CTimestamp::getTimestamp() function, I found that it happens with dates before 1942-11-02 02:00:00, in this cases the function gives back a wrong timestamp, I didn’t well understand why but it’s probably related to the GMT timezone, I’m in Italy/Rome timezone so GMT+1, probably before 1942-11-02 something was different? However getTimestamp gives a different result than strtotime and consequentially a wrong time (probably this happens also for other countries in the same timezone)

The fact that you Backslider have a correct result is probably due you are on a GMT timezone different than me.

I found some topics similar to this but probably those don’t concentrate on this specific function.

http://code.google.com/p/yii/issues/detail?id=161

http://code.google.com/p/yii/issues/detail?id=470

At this point if there’s no opposite opinions I should open a bug ticket…