Title: Date
1Date Time
- ????????? ??????????
- ???????????????????????????????????????
- ????????????????? ?????
2???????
- ????????????????????????????????????
- ???????????????????? (Calendar)
3????????????????????????????????????
- ?????????????? date()
- ?????????????? getdate()
- ????????????????????????????????????????
4?????????????? date()
date(string format)
??????
- ???????????????????????????????????
??????????????????????????????????????????????????
??????????????
format ???????????????????????????????????
5FORMAT
Code ????????
a ???????????? ???????? ???????????????? "am" ???? "pm"
A ???????????? ???????? ???????????????? "AM" ???? "PM"
B ?????????????????????? http//www.swatch.com/internettime/home.php
d ????????????????? 2 ???? ??? 01 ??? 31
D ????????????????? 3 ???? ??? Mon ??? Sun
F ???????????????????? ??? January ??? December
6FORMAT
Code ????????
g ??????????? ???????? 12 ??. ??? 1 ??? 12
G ??????????? ???????? 24 ??. ??? 0 ??? 23
h ??????????? ???????? 12 ??. ??? 01 ??? 12
H ??????????? ???????? 24 ??. ??? 00 ??? 23
i ???????? ???????? 00 ??? 59
I ????????????? Daylight saving ???????????????? 1 ???????????????? Daylight saving ???????????????? 0
7FORMAT
Code ????????
j ?????????? ??? 1 ??? 31
l ?????????????????? ??? Monday ??? Sunday
L ?????????? 1 ????????????????????? ??? 0 ???????????????????????
m ??????????????????? 2 ???? ??? 01 ??? 12
M ???????????????????????????? 3 ???????? ??? Jan ??? Dec
n ??????????????????? ??? 1 ??? 12
s ???????????????????? 2 ???? ??? 00 ??? 59
8FORMAT
Code ????????
S ?????????????????? ???? st, nd, rd ???? th
t ???????????????????????????? ???? 28 29 30 31
T ??????? Time zone ???? 3 ???????? ???? EST
U ????????????????????? 1 ?.?. ?.?.1970 ?????????????
w ??????????????????????????????????? 0 ????????????? 1 ???????????? 6 ???????????
y ?????? ?.?. ??????? 2 ???????? 05
9FORMAT
Code ????????
Y ?????? ?.?. ??????? 4 ???????? 2005
z ??????????????????? ??? 0 ??? 365
Z ???????????? Time zone ???????? ??? -43200 ??? 43200
10Example date()
Mon 26 December 2005
- lt?php
- echo "lth1gt"
- echo date("D j F Y")
- echo "lt/h1gt"
- ?gt
11?????????????? getdate()
array getdate(int timestamp)
??????
- ????????????????????????????????????????? date()
?????????????????????????????????????
timestamp ??????????????????????
12FORMAT
Key ????????
seconds ?????? ??????????
minutes ???? ??????????
hours ??????? ??????????
mday ??????????????? ??????????
wday ????????????????? ??????????
mon ????? ??????????
year ?? ??????????
13FORMAT
Key ????????
yday ???????????? ??????????
weekaday ????????????????? ????????????
month ????? ????????????
14Example getdate()
December 26 2005
- lt?php
- today getdate()
- month today"month"
- mday today"mday"
- year today"year"
- echo "lth1gt"
- echo month . " " . mday . " " . year
- echo "lt/h1gt"
- ?gt
15Example getdate()
Time 195217
- lt?php
- time getdate()
- hour time "hours"
- minute time "minutes"
- second time "seconds"
- echo "lth1gt"
- echo "Time " . hour . "" . minute . "" .
second - echo "lt/h1gt"
- ?gt
16?????????????? checkdate()
int checkdate(int month, int day, int year)
??????
- ?????????????????????????????????????????????
month ????????????? 1-12
day ????????????? 1-31
year ????????
17Example getdate()
Incorrect Date!!
- lt?php
- if(checkdate(31, 10, 2005)) echo "Correct
Date!!" - else echo "Incorrect Date!!"
- ?gt
18????????????????????????????????????????
Show Thai Date 12/31/2005 31 ?.?. 2548
- lt?php
- function dateTHAI(date)
-
- year substr("date", 0, 4)
- year year 543
- thaimonth array("?.?.", "?.?.", "??.?.",
"??.?.", "?.?.", "??.?.", "?.?.", "?.?.", "?.?.",
"?.?.", "?.?.", "?.?.") - month substr("date", 4, 2)
- month (int)month - 1
- month thaimonthmonth
19????????????????????????????????????????
- day substr("date", 6, 2)
-
- return (int)day . " " . month . " " . year
- // end function
- echo "Show Thai Date ltbr/gt"
- echo "12/31/2005 " . dateTHAI('20051231')
- ?gt