The example below outputs the dates for the next six Saturdays:
Example:
<?phpThe example below outputs the number of days until 4th of July:
$startdate = strtotime("Saturday");
$enddate = strtotime("+6 weeks",$startdate);
while ($startdate < $enddate) {
echo date("M d", $startdate),"<br>";
$startdate = strtotime("+1 week", $startdate);
}
?>
Example:Create a Date With PHP mktime()
<?php
$d1=strtotime("July 04");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . days until 4th of July.";
?>
The optional timestamp parameter in the date() function specifies a
timestamp. If you do not specify a timestamp, the current date and time
will be used (as shown in the examples above). The Unix timestamp
contains the number of seconds between the Unix Epoch (January 1 1970
00:00:00 GMT) and the time specified.
Syntax:
mktime(hour,minute,second,month,day,year)
The example below creates a date and time from a number of parameters in the mktime() function:
Example:
<?php
$d=mktime(11, 14, 54, 8, 12, 2014);
echo "Created date is " .
Tidak ada komentar:
Posting Komentar