mirror of
https://github.com/friendica/friendica
synced 2025-04-28 03:50:17 +00:00
Add Temporal::localNow() shorthand for Temporal::convert()
This commit is contained in:
parent
89602e44da
commit
a2ee2b56d2
5 changed files with 23 additions and 12 deletions
|
@ -136,7 +136,7 @@ class Temporal
|
|||
}
|
||||
|
||||
/**
|
||||
* convert() shorthand for UTC now.
|
||||
* convert() shorthand for timezoned now.
|
||||
*
|
||||
* @param string $format DateTime format string or Temporal constant
|
||||
* @return string
|
||||
|
@ -146,6 +146,17 @@ class Temporal
|
|||
return self::convert('now', $timezone, 'UTC', $format);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert() shorthand for local now.
|
||||
*
|
||||
* @param string $format DateTime format string or Temporal constant
|
||||
* @return string
|
||||
*/
|
||||
public static function localNow($format = self::MYSQL)
|
||||
{
|
||||
return self::convert('now', date_default_timezone_get(), 'UTC', $format);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert() shorthand for UTC now.
|
||||
*
|
||||
|
@ -542,8 +553,8 @@ class Temporal
|
|||
'October', 'November', 'December'
|
||||
];
|
||||
|
||||
$thisyear = self::timezoneNow(date_default_timezone_get(), 'Y');
|
||||
$thismonth = self::timezoneNow(date_default_timezone_get(), 'm');
|
||||
$thisyear = self::localNow('Y');
|
||||
$thismonth = self::localNow('m');
|
||||
if (!$y) {
|
||||
$y = $thisyear;
|
||||
}
|
||||
|
@ -560,7 +571,7 @@ class Temporal
|
|||
$started = false;
|
||||
|
||||
if (($y == $thisyear) && ($m == $thismonth)) {
|
||||
$tddate = intval(self::timezoneNow(date_default_timezone_get(), 'j'));
|
||||
$tddate = intval(self::localNow('j'));
|
||||
}
|
||||
|
||||
$str_month = day_translate($mtab[$m]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue