วันเสาร์ที่ 10 พฤศจิกายน พ.ศ. 2555

PHP - Date/Time Function


1. checkdate

  สำหรับตรวจสอบ วัน เดือน ปี ที่กำหนดว่าอยู่ในช่วงหรือไม่  จะอยู่ในช่วงก็จะ return ค่า 1 กลับ มีรูปแบบคือ

Int checkdate (int month, int date, int year).

2. Date

จะแสดงค่าวันที่เวลาตามที่กำหนดตาม formal ไป ส่วน timestamp จะเอาไว้สำหรับแสดงเวลาของสถานที่ต่าง ๆ  บนโลก  ถ้าไม่กำหนดจะแสดง locatime มีรูปแบบคือ

String date(string format, int timestamp)

Format string ใช้สำหรับแสดงเวลาแบบต่าง ๆ

U – seconds since the epoch
  Y – year, numeric, 4 digits
y -  year, numeric, 2 digits
F – month, textual, long; i.e. “January”
M – month, textual, 3 letters; i.e. “Jan”
m - month, unmeric
  z – day of the year, numeric
l (lowercase ‘L’) – day of the week, textual, long; i.e. “Friday”
D – day of the week, textual, 3 letters; i.e. “Fri”
      w - day of the week, numeric, 1 digit
H – hour, numeric, 24 hour format
h - hour, numeric, 12 hour format
i - minutes, numeric
  s - seconds, uumeric
  A – “AM” or “PM”
  a - “am”or”pm”
S – English ordinal suffix, textual, 2 characters; i.e. “th”, “nd”

ตัวอย่าง
                            Print(date(“I dS of F Y h:I:s A”));

จะได้ Saturday  12 th February 2000 01:15:23 AM

3. mktime

แสดงวินาที่นับตั้งแต่เวลาของ UNIX Epoch(January 1, 1970) จนถึงวันที่กำหนด มีรูปแบบ

Int mktime(int hour, int minute, int second, int month, int day, int year);

4. time

แสดงวินาที่ที่นับตั้งแต่เวลาของ UNIX Epoch(January 1, 1970). มีรูปแบบคือ

Int time()

5. Set_time_limit

กำหนดเวลาที่ script ทำงานอยู่ เช่น set_time_limit(30) หลังจากนั้น scripts ก็จะ fatal error มีรูปแบบคือ

Void set_time_limit (int seconds);




ไม่มีความคิดเห็น: