function CurrentDateTime() { $CurrentDateTime = '' . CurrentDate() . ' ' . CurrentTime() . ''; return $CurrentDateTime; }
function SmartDateTime($dt, $now = null) { if ($now == null) { $now = CurrentTime(); } # dt와 now가 문자열 'yyyy-mm-dd hh:mm:ss' 이면 array로 변환하여 계산 if (is_string($dt)) { $dt = DateStringToArray($dt); } if (is_string($now)) { $now = DateStringToArray($now); } if ($dt['year'] == $now['year'] && $dt['month'] == $now['month'] && $dt['day'] == $now['day']) { # 같은 날짜이면 시간만 출력함 # 같은 날짜이면 날짜와 시간을 모두 출력함 $str = sprintf("%04d-%02d-%02d", $dt['year'], $dt['month'], $dt['day']); $str .= sprintf(" %02d:%02d:%02d", $dt['hour'], $dt['min'], $dt['sec']); } else { # 서로 다른 날짜이면 날짜만 출력함 $str = sprintf("%04d-%02d-%02d", $dt['year'], $dt['month'], $dt['day']); } return $str; }