|
|
<?
$date1=mktime($hour1,$minute1,$second1,$month1,$day1,$year1);
$date2=mktime($hour2,$minute2,$second2,$month2,$day2,$year2);
$diff_in_secs=$date2 - $date1;
$diff_in_days=$diff_in_secs / 86400;
?>
|
|
| If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used. Categories : HTML and PHP, PHP, Date Time | | | Calendar using Date function Categories : HTML and PHP, PHP, Date Time, Calendar | | | Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields Categories : MySQL, Date Time, PHP, Databases | | | Count Number Of weeks in Month Categories : PHP, Date Time, Beginner Guides | | | table calendar pretty much does what cal(1) does - prints out a calendar.
Categories : Date Time, PHP, Calendar | | | Simple function to return the number of days in a time span between 2 given dates. Categories : PHP, Date Time, MySQL, Databases | | | Calendar class on the same page , suitable for reservation
Categories : PHP, Calendar, Date Time | | | Date Validation using JavaScript. Intended to use it as checkdate() from PHP. Categories : Java Script, Date Time, PHP | | | Calendars to choose a range of dates , reservation events ... Categories : PHP, Calendar, Java Script, Date Time | | | CALENDAR - easy calendar-navigation with PHP Categories : PHP, Date Time, HTML and PHP, Calendar | | | a class that uses microtime() to provide easy calculation of elapsed times
Categories : Date Time, PHP, PHP Classes | | | Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays. Categories : Calendar, Date Time, PHP, Databases, MySQL | | | Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL | | | Local-to-user date and time display regardless of time zone or where the website's server is located Categories : PHP, Date Time, HTML and PHP, Java Script | |
| |
| | | | | Yared wrote : 467
function get_day_diff($date_1, $date_2)
{
/*=================================================================
Requires: date_1 to be greater than date_2
Description: This will return the difference in days
between two PHP timestamps
===================================================================*/
$day_diff = ($date_1 - $date_2) / 86400;
return($day_diff);
} // end get_day_diff
| | | | Yared wrote : 468
Use this function to get the timestamp
function get_timestamp($date)
{
/* ===================================
Require:
date to be YYYY-MM-DD format
Description"
Take a date in YYYY-MM-DD format and return
it to the user in a PHP timestamp
=============================== Yared*/
// split the array
$date_array = explode("-",$date);
$year = $date_array[0];
$month = $date_array[1];
$day = $date_array[2];
$timestamp = mktime(0,0,0,$month,$day,$year);
return($timestamp); // return it to the user
}
| | | | Christian Seip wrote : 570
Change
$diff_in_secs=$date2-$date1;
to
$diff_in_secs=abs($date1-$date2);
and you don`t need to care anymore which of both dates is greater.
| | | | chris christodoulou wrote :721
<?
$today = date("d m y");
$week = date("d m Y",time() + 604800); //604800 is 7 days from today (24 hrs * (60min * 60sec)) * 7 days = 604800
$difference = $week - $today;
echo"Today is: $today<br>";
echo"Tomorrow: $week<br>";
echo"$difference";
//simple and working
?>
| |
|
|