function last_day_of_feb ($year) {# The 0th day of a month is the same as the last day of the month before$ultimo_feb_str = $year . "-03-00"; $ultimo_feb_date = date_create($ultimo_feb_str);$return = date_format($ultimo_feb_date, "Y-m-d"); return $return;}

DateTime()->format() will modify the timezone. So do not expect the public date property to be returned (format mask applied) based on the current public timezone property. format will decide that when calling ->format() it will use the server timezone which eliminates all usefulness of ->setTimezone().

The udate function is a great start, but the formatting of the milliseconds is a little off. If it is within the first 100000 microseconds then the string will be less than 6 characters, so 0.012435 will appear as 0.12345. The revision below fixes this.

function udate($strFormat = 'u', $uTimeStamp = null){

// If the time wasn't provided then fill it in if (is_null($uTimeStamp)) { $uTimeStamp = microtime(true); }

// Round the time down to the second $dtTimeStamp = floor($uTimeStamp);

// Replace the milliseconds in the date format string // Then use the date function to process the rest of the string return date(preg_replace('`(?<!\\\\)u`', $strMilliseconds, $strFormat), $dtTimeStamp);}