convertFormatToFormat() public static method

This will be useful to directly convert time strings coming from databases. Example: Suppose this comes from database $a = '2016-02-14 14:20:38'; $date = \jDateTime::convertFormatToFormat('Y-m-d H:i:s', 'Y-m-d H:i:s', $a); $date will now be '۱۳۹۴-۱۱-۲۵ ۱۴:۲۰:۳۸'
Author: Vahid Fazlollahzade
public static convertFormatToFormat ( string $jalaliFormat, string $georgianFormat, string $timeString, null | DateTimeZone | string $timezone = null ) : string
$jalaliFormat string Return format. Same as static::date(...)
$georgianFormat string The format of $timeString. See php.net/date
$timeString string The time itself, formatted as $georgianFormat
$timezone null | DateTimeZone | string The timezone. Same as static::date(...)
return string
Exemplo n.º 1
0
 public function testConvertFormatToFormat()
 {
     $a = '2016-02-14 14:20:38';
     $date = \jDateTime::convertFormatToFormat('Y-m-d H:i:s', 'Y-m-d H:i:s', $a, 'Asia/Tehran');
     $this->assertEquals($date, '۱۳۹۴-۱۱-۲۵ ۱۴:۲۰:۳۸');
 }