$length =
strlen($format);
$output = '';
for ($i = 0;
$i <
$length;
$i++
) { switch($format[$i]) { // day formats
case 'd': // day of month, 2 digits, with leading zero, 01 - 31
$output .= (($date['mday'
] < 10
) ? '0' .
$date['mday'
] :
$date['mday'
]);
break;
case 'D': // day of week, 3 letters, Mon - Sun
$output .=
date('D', 86400 *
(3 + self::
dayOfWeek($date['year'
],
$date['mon'
],
$date['mday'
])));
break;
case 'j': // day of month, without leading zero, 1 - 31
$output .=
$date['mday'
];
break;
case 'l': // day of week, full string name, Sunday - Saturday
$output .=
date('l', 86400 *
(3 + self::
dayOfWeek($date['year'
],
$date['mon'
],
$date['mday'
])));
break;
case 'N': // ISO 8601 numeric day of week, 1 - 7