🚀 DevOps Certified Professional
📅 Starting: 1st of Every Month 🤝 +91 8409492687 | 🤝 +1 (469) 756-6329 🔍 Contact@DevOpsSchool.com

PHP Mktime Function

DevOps

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

The Mktime() function is an inbuilt function in PHP which is used to return the Unix timestamp for a date. The timestamp returns a long integer containing the number of seconds between the Unix Epoch (January 1, 1970, 00:00:00 GMT) and the time specified.

Syntax:

Int Mktime( $hour, $minute, $second, $month, $day, $year, $is_dst)

parameters

This function has seven optional parameters as mentioned below:

$hour: It is a parameter which specifies the hour.
$minute: It is a parameter which specifies the minute.
$second: It is a parameter which specifies the second.
$month: It is a parameter which specifies the month.
$day: It is a parameter which specifies the day.
$year: It is a parameter which specifies the year.
$is_dst: It is a parameter which can be set to 1 if the time is during daylight savings time (DST), or 0 if it is not.

<?php

// Using mktime() function to know the day
echo "May 21,2022 was on a " . date("l",
mktime(3, 12, 15, 5, 21, 2022));
?>

Output
May 1, 2022 was on a saturday
<?php

// Using mktime() function to know the complete date
echo date("M-d-Y", mktime(0, 0, 0, 5, 21, 2022)) . "<br>";

// Using mktime() function to know the
// complete date for an out-of-range input
echo date("M-d-Y", mktime(0, 0, 0, 6, 21, 2022));

?>

Output

May-05-2022
May-06-2022
Subscribe
Notify of
guest


This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x