Relative Formats
이 페이지에서는 strtotime(), DateTime 및 date_create() 파서가 이해하는 다양한 상대적 날짜/시간 형식에 대해 설명합니다.
Used Symbols
설명 | Formats |
---|---|
dayname |
'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' |
daytext |
'weekday' | 'weekdays' |
number |
[+-]?[0-9]+ |
ordinal |
'first' | 'second' | 'third' | 'fourth' | 'fifth' | 'sixth' | 'seventh' | 'eighth' | 'ninth' | 'tenth' | 'eleventh' | 'twelfth' | 'next' | 'last' | 'previous' | 'this' |
reltext |
'next' | 'last' | 'previous' | 'this' |
space |
[ \t]+ |
unit |
(('sec' | 'second' | 'min' | 'minute' | 'hour' | 'day' |
'fortnight' | 'forthnight' | 'month' | 'year') 's'?) | 'weeks' |
daytext |
Day-based Notations
Format | 설명 | Examples |
---|---|---|
'yesterday' | Midnight of yesterday | "yesterday 14:00" |
'midnight' | The time is set to 00:00:00 | |
'today' | The time is set to 00:00:00 | |
'now' | Now - this is simply ignored | |
'noon' | The time is set to 12:00:00 | "yesterday noon" |
'tomorrow' | Midnight of tomorrow | |
'back of' hour |
15 minutes past the specified hour | "back of 7pm", "back of 15" |
'front of' hour |
15 minutes before the specified hour | "front of 5am", "front of 23" |
'first day of' | Sets the day of the first of the current month. This phrase is best used together with a month name following it. | "first day of January 2008" |
'last day of' | Sets the day to the last day of the current month. This phrase is best used together with a month name following it. | "last day of next month" |
ordinal space dayname space 'of' |
Calculates the x -th week day of the current month. |
"first sat of July 2008" |
'last' space dayname space 'of' |
Calculates the last week day of the current month. | "last sat of July 2008" |
number space ? (unit | 'week') |
Handles relative time items where the value is a number. | "+5 weeks", "12 day", "-7 weekdays" |
ordinal space unit |
Handles relative time items where the value is text. | "fifth day", "second month" |
'ago' | Negates all the values of previously found relative time items. | "2 days ago", "8 days ago 14:00", "2 months 5 days ago", "2 months ago 5 days", "2 days ago" |
dayname |
Moves to the next day of this name. | "Monday" |
reltext space 'week' |
Handles the special format "weekday + last/this/next week". | "Monday next week" |
메모:
상대 명령문은 항상 비 상대 명령문 다음에 처리됩니다. 이렇게 하면 "2008년 7월 +1주"와 "2008년 7월 +1주"가 됩니다.
이 규칙의 예외는 "어제", "자정", "오늘", "정오" 및 "내일"입니다. "내일 11:00"과 "내일 11:00"은 다릅니다. "2008년 7월 23일"이라는 오늘 날짜를 고려하면 첫 번째 날짜는 "2008-07-24 11:00"을 생성하고 두 번째 날짜는 "2008-07-24 00:00"을 생성합니다. 그 이유는 이 다섯 문장이 현재 시간에 직접적인 영향을 미치기 때문입니다.
메모:
현재 요일이 날짜/시간 문자열에 사용된 요일과 동일한 경우 다음 설명을 확인하세요. 그러나 현재 요일은 날짜/시간 문자열의 상대적이지 않은 부분에 의해 (재)계산될 수 있습니다.
- "
dayname
" does not advance to another day. (Example: "Wed July 23rd, 2008" means "2008-07-23"). - "
number
dayname
" does not advance to another day. (Example: "1 wednesday july 23rd, 2008" means "2008-07-23"). - "
number
weekdayname
" will first add the number of weeks, but does not advance to another day. In this case "number
week" and "dayname
" are two distinct blocks. (Example: "+1 week wednesday july 23rd, 2008" means "2008-07-30"). - "
ordinal
dayname
" does advance to another day. (Example "first wednesday july 23rd, 2008" means "2008-07-30"). - "number week
ordinal
dayname
" will first add the number of weeks, and then advances to another day. In this case "number week" and "ordinal
dayname
" are two distinct blocks. (Example: "+1 week first wednesday july 23rd, 2008" means "2008-08-06"). - "
ordinal
dayname
'of' " does not advance to another day. (Example: "first wednesday of july 23rd, 2008" means "2008-07-02" because the specific phrase with 'of' resets the day-of-month to '1' and the '23rd' is ignored here).
또한 "ordinal
space
dayname
space
'of' " 및 "'last' space
dayname
dayname
'of' "에서 "of"가 특별한 일을 한다는 점을 관찰하십시오.
- It sets the day-of-month to 1.
- "
ordinal
dayname
'of' " does not advance to another day. (Example: "first tuesday of july 2008" means "2008-07-01"). - "
ordinal
dayname
" does advance to another day. (Example: "first tuesday july 2008" means "2008-07-08", see also point 4 in the list above). - "'last'
dayname
'of' " takes the last dayname of the current month. (Example: "last wed of july 2008" means "2008-07-30") - "'last'
dayname
" takes the last dayname from the current day. (Example: "last wed july 2008" means "2008-06-25"; "july 2008" first sets the current date to "2008-07-01" and then "last wed" moves to the previous Wednesday which is "2008-06-25").
메모: 상대 월 값은 통과하는 월의 길이를 기준으로 계산됩니다. 예는 "+2month 2011-11-30"이고 "2012-01-30"을 생성합니다. 이는 11월이 30일이고 12월이 31일로 총 61일이 생성되기 때문입니다.
메모: number
는 정수입니다. 10진수가 주어지면 점(또는 쉼표)이 구분 기호로 해석될 수 있습니다. 예를 들어 '+1.5 hours'
은 '+1 hour +30 minutes'
이 아니라 '+1 5 hours'
과 같이 구문 분석됩니다.
변경 로그
버전 | 설명 |
---|---|
7.0.8 | 주는 항상 월요일에 시작합니다. 이전에는 일요일도 한 주를 시작하는 것으로 간주되었습니다. |