PHP Date function
1- Date()

 

Date function print day,month,year etc. following format are given below.

Format character are :-

Format character Meaning Output
M Print month with three letter Jan, Feb…
m Print month with Numeric value 01,12…..
y print year with two digit 98,10
Y Print year with four digit 1998,2010
d Print day of the month with 2 digits 01,31
D Print day with three letter Mon,Tue


Return Type :- string

<?php

echo date("m") . "<br />";
echo date("M") . "<br />";
echo date("y") . "<br />";
echo date("Y") . "<br />";
echo date("d") . "<br />";
echo date("D") . "<br />";
echo date("M/d/Y") . "<br />";

?>

Output:-
01
Jan
10
2010
14
Thu
Jan/14/2010
2- time()

This function returns the current UNIX timestamp.

Note :- This function return second start from (January 1 1970 00:00:00 GMT).

Return Type:- int

<?php

echo time();

?>

Output :-
1286865926

3- microtime()

This function returns the current UNIX timestamp with microseconds.

Note :- microsecond(1/1000000) in 1 second . that is very small unit.

Return Type:- mixed

<?php

echo microtime();

?>

Output :-
0.43751100 1287612083
here 0.43751100 is microsecond and 1287612083 is unixtimestamp


Previous
Next