formatDate() public méthode

public formatDate ( $fmt, $ts = false, $is_gmt = false ) : string
Résultat string formatted date based on timestamp $d
 function testRandomDates()
 {
     $start = 1960 + rand(0, 10);
     $yrs = 12;
     $i = 365.25 * 86400 * ($start - 1970);
     $offset = 36000 + rand(10000, 60000);
     $max = 365 * $yrs * 86400;
     $lastyear = 0;
     $s = new TDateTimeStamp();
     // we generate a timestamp, convert it to a date, and convert it back to a timestamp
     // and check if the roundtrip broke the original timestamp value.
     //print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
     $fails = 0;
     for ($max += $i; $i < $max; $i += $offset) {
         $ret = $s->formatDate('m,d,Y,H,i,s', $i);
         $arr = explode(',', $ret);
         if ($lastyear != $arr[2]) {
             $lastyear = $arr[2];
         }
         $newi = $s->getTimestamp($arr[3], $arr[4], $arr[5], $arr[0], $arr[1], $arr[2]);
         if ($i != $newi) {
             // This actually can fail if $i is in the middle of a time change due to DST
             $tz = new DateTimeZone(date_default_timezone_get());
             $transitions = $tz->getTransitions($i - 3600, $i + 3600);
             if (count($transitions) == 0) {
                 $fails++;
             }
             //$j = mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]);
             //print "Error at $i, $j, getTimestamp() returned $newi ($ret)\n";
         }
     }
     $this->assertEquals($fails, 0);
 }