DATE TIME
열을 더 읽기 쉬운 시간 (예 : 9:51)으로 출력하는 날짜 기능이 있습니다. 그러나 내 날짜가 읽고있는 시간대는 내 서버가있는 곳으로 CST, US입니다. EST를 읽을 수있는 방법이 있습니까? 심지어 어떤 지역의 정확한 시간을 표시 할 수 있습니까?날짜 기능을 올바른 시간대로 설정하십시오.
function fixDate($strDateTime) {
$strFormat = 'M, j, Y';
$strFormatTime = '\a\t g:ia';
$intTimeStamp = strtotime($strDateTime);
$strDate = date($strFormat, $intTimeStamp);
$strTime = date($strFormatTime, $intTimeStamp);
if($strDate == date($strFormat)) {
return "Today " . $strTime;
}
elseif($strDate == date($strFormat, strtotime('yesterday'))) {
return "Yesterday " . $strTime;
}
else {
return $strDate . " " . $strTime;
}
}
[DateTime] (http://php.net/manual/es/class.datetime.php) 및 [DateTime-> setTimezone] (http://php.net/manual/ es/datetime.settimezone.php) 당신은 문자열 대신에'DateTime' 객체를받을 수 있고 당신의 날짜를 "prettifying"하기 전에 그것을 클라이언트'DateTimeZone'로 변환 할 수 있습니다. 이것은 클라이언트 측에서 더 쉽지만 AFAIK 서버에서 수행 될 수 있습니다. – jorgonor