|
|
|
<?
$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;
?>
|
|
| A Timing Class Categories : PHP, PHP Classes, Date Time | | | Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time | | | A wrapper function to format dates coming from a databases with the
same syntax as PHP's date() function. Categories : Date Time, Databases, PHP | | | pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP, PHP Classes, Calendar, Date Time | | | PHP Round Clock - Must have Gif support to use this. Categories : PHP, Date Time, Graphics | | | A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time, PHP, Complete Programs, Calendar | | | Open and Close your website in fixed times . Categories : PHP, PHP Classes, Cron, Date Time | | | mysql date/time converters Categories : PHP, MySQL, Databases, Date Time | | | 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 | | | If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example. Categories : PHP, Date Time, PHP Classes, Calendar | | | calculus of the eastersunday Categories : BC math, PHP, Date Time, Databases | | | Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June). Categories : Calendar, Date Time, PHP | | | Monthly and Daily Upcoming Events calendar. Categories : Date Time, PostgreSQL, PHP, Calendar, Databases | |
| | | | 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
?>
| |
|
|
|