Reputation: 1383
$time = Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->date]);
in my localhost $time is persian (jalali) and after upload $time is english(Gregorian )
how can i change my $time to jalali (perisan)????
Upvotes: 0
Views: 73
Reputation: 81
You should set the timestamp property time_zone as shown bellow:
date_default_timezone_set('Asia/Tehran');
Another way you can use this function to convert Gregorian to Persian after upload:
public function gregorianToPersian($gregorian)
{
date_default_timezone_set('Asia/Tehran');
$gregorian = date_parse($gregorian);
$persian = $this->fromGregorian([$gregorian['year'], $gregorian['month'],
$gregorian['day'], $gregorian['hour'], $gregorian['minute'],
$gregorian['second']])->toPersian('en')->asDateTime();
return $persian;
}
Upvotes: 3