PHP Data and Time Function
PHP Data and Time
The dete() function accept a format string as parameter
formate the local date and time specified format
Syntax :-
mktime(hour, minute, second, month, day, year)
date(format,timestamp)
data () funtion
d = Represents the day of month (1 to 31)
m = Represen
ts a month (1 to 12)
y = Represents a year (4 digits)
l = Represents the day of the week
Time () Function :-
Returns the Current time in the number of the seconds
time() function used return the courrent time
H - 24 - hour (00 to 23)
i - Minutes with (00 to 59)
s - Second with leading (00 to 59 )
a - Lowercase ante meridiem and post meridiem (am to pm)
ஃ Default timezone
date _default_timezone_set('UTC');
፨ Default Timezone UTC
ஃ Current date and time
$currentDateTime = date('Y-m-d H:i:s') ;
፨ YYYY-MM-DD-HH-MM:SS
ஃ Current date format
$currentDate = date('F j,Y');
፨ Month day , Year
ஃ Current time
$currentTime12Hr = date('h:i:s A');
፨ hh: mm:ss AM/PM
Example :-
<?php
echo "Today is " . date("y/m/d") . "<br>";
echo "Today is" . date("y.m.d") . "<br>";
echo "Today is" . date(y-m-d") ."<br>";
echo "Today is ". date("l");
?>
Output :-
2] Date :-
Example
<?php
$day =date("d/m/y");
echo $day;
Output :-
3] Day :-
Example :-
<?php
echo "Today is ". date("l");
?>
Output :-
4] Date :-
Example :-'
<?php
$d= mktime(11,14,54,8,12 ,2014);
echo " date " . date("y-m-d h:i:sa");
?>
Output :-
OutPut :-
Example:-
<?php $date = date("D M d y");
print ("Date :-". $date);?>
Output :-
<?php
$date = date("D M d y");
print ("Date :-". $date);
?>
Example:-
<?php
date_default_timezone_set('UTC');
echo date("l");
echo "
";
echo date('l dS \of F Y h:i:s A');
echo "
";
?>
Post a Comment