Mktime function to generate time stamp of any date and timeWe can generate time stamp for any given date and time by using mktime function of PHP. This function is useful in doing date calculations like finding difference in two dates. We will learn how to use mktime() function along with date function to generate and check different time stamps. Here is the general syntax of mktime() function of PHP.
mktime (hour, minute, second, month, day, year)This function takes all these inputs and returns a integer having the time stamp in seconds. Time stamp in second is the gap in seconds between given time and January 1 1970 00:00:00 GMT.
Let us try to find out the time stamp of 1st January 2007, 22 hours and 30 minutes & 0 seconds. We will write this code.
The output of the above code is 1167670800. To check the output let us use date function and use this input and find out the date.
Click for more tutorial on Date & Time functions and Applications
PHP Date & Time functions
PHP Date Timestamp and generating date & time in different formats
Validating Date: Checking if date is correct or not by using checkdate()
PHP Date Today: Getting current date, week day and month
PHP yesterday and previous 7 days from today
Vaious date formats to use in date function and class
Time stamp generator: Use any date and time and generate timestamp
Date selection drop down list box for users to select
mktime function to generate time stamp
Difference in Two dates by using mktime function
Finding month, weekday, day of the year etc for any date value
Breaking the date string to get month date and year using array
More On Date Object
PHP Date & Time class creating and examples of uses
Creating a date interval object and using with php date object
Adding date interval to date object to create new dates
Difference in date by using diff function and using date object
Add or subtract from date object using modify function
Changing parameters of the date object by using setdate function
updating time for a date object to a new value
Gettign the time zone setting of the server
Setting the default time zone of server
Array of time zones available for setting ( total list )
Getting time in seconds elapsed from Epoch time
Local time of the server or different time zones by using localtime() function