Kamis, 23 April 2009

DATE TIME FUNCTION

A. checkdate function
function : used to check validation of the date. Argument must be an integer and have result in 2 kind of value, true or false.
Sintax : checkdate(month,date,year);
note : * month : a month argument in a format number .
* date : a date argument in a format number.
* year : a year argument in format 2 digits or 4 digits.
Example : if(checkdate($bln,$tgl,$thn)){
echo”
valid date”;
}else{
echo”
invalid date”:
}
?>

B. time function
function : used to read time in a second from 1 january 1970 at 00:00:00 until this script made.
Sintax : time()

C. date function
function : used to get date/time from computer system.
Sintax : Date(string_format);
note: * string_format : is a string that's contain certain character as time format
Argument Result
a “am” or “pm”
A “AM” or “PM”
d Date with 2 digits length (“01”-”31”)
D Days name with 3 character length (“sun”,”mon”,..)
F Name of month with completed format (“january”)
g hours with 12 hours format (“1”-”12”)
G hours with 24 hours format (“0”-”24”)
H hours with 2 digits format (“00”-”23”)
h hours with 12 hours and 2 digits length (“01”-”12”)
i Minute with 2 digits format (“00”-”59”)
J Date (now) “1”-”31”
l Day name at now with complete format (“monday”)
L “0” if the years is not leap year
“1” if the years is leap year (leap = kabisat)
m Name of month with 2 digits format (“01”-”12”)
M Name of month with 3 character format (“jan”)
n Name of month without 0 in the front (“1”-12”)
R Date with RFC 822 format
s Second with format “00”-”59”
S Suffix “th” or “nd” or “st”
t Amount of day in a month (“28”-”31”)
T Timezone setting in machine, like as “MDT”
w Code of the day in number, like as :
“0” = sunday
“1” =monday, etc
Y Year in 4 digits format (“2009”)
y Year in 2 digits format (“09”)
z Date in a year (“0”-”365”)

example : $format1=date(“d-m-y”);
$format2=date(“d-F-Y”);
$format3=date(“l,d-F-Y”);
$format4=date(“G:i:s”);
$format5=date(“g:i:s A”);
?>
result : format1 : 25-03-09
format2 : 25-march-2009
format3 : Wednesday, 25-march-2009
format4 : 10:29:09
format5 : 10:29:09 AM

D. Date function with 2 argument
function: date function can be write using 2 argument, second argument is a formatted time that used date function.
Sintax : date(string_format,time);
note : * string_format : string thats contain certain character, and it will be time format
* time : is a time in a number which showing a second
example: $now=date();
$dayzz=$now+(2*24*60*60);
?>
result : $now= 25-march-2009
$dayzz = 27-march-2009

Tidak ada komentar:

Posting Komentar