Hi
anybody help me calculate number of days in between two dates?
calculating date differences
Moderator: General Moderators
Wish I could paste this in HTML so you could see the colors without me spending alot of time converting. However if you would like to see it go to my site here. http://www.coastgames.com/html.php?link=11
Time difference. Days past. Timestamp in format of mm/dd/yyyy
$day=substr($timestamp, 3, 2);
$month=substr($timestamp, 0, 2);
$year=substr($timestamp, 6, 4);
// Calculations
$startday = mktime ("", "", "", $month, $day, $year); // get unix time for start date
$today = time(); // todays
$difference = $today - $startday; // work out the difference
$show = floor($difference / 86400);
Time Difference. Days to come. Timestamp in format of mm/dd/yyyy
$day=substr($timestamp, 3, 2);
$month=substr($timestamp, 0, 2);
$year=substr($timestamp, 6, 4);
// Calculations
$startday = mktime ("", "", "", $month, $day, $year); // get unix time for start date
$today = time(); // todays
$difference = $startday - $today; // work out the difference
$show = floor($difference / 86400);
--------------------------------------------------------------------------------
Lets break it down. Timestamp example 10/31/2002
$month=substr($timestamp, 0, 2); (This is taking the first 2 digits for the month.)
$day=substr($timestamp, 3, 2); (This is taking the 4th and 5th digit for the day.)
$year=substr($timestamp, 6, 4); (This is takign the 7th through 10th digits for the year.)
// Calculations
$startday = mktime ("", "", "", $month, $day, $year); // get unix time for start date
$today = time(); // todays
$difference = $startday - $today; // work out the difference
$show = floor($difference / 86400);
Time difference. Days past. Timestamp in format of mm/dd/yyyy
$day=substr($timestamp, 3, 2);
$month=substr($timestamp, 0, 2);
$year=substr($timestamp, 6, 4);
// Calculations
$startday = mktime ("", "", "", $month, $day, $year); // get unix time for start date
$today = time(); // todays
$difference = $today - $startday; // work out the difference
$show = floor($difference / 86400);
Time Difference. Days to come. Timestamp in format of mm/dd/yyyy
$day=substr($timestamp, 3, 2);
$month=substr($timestamp, 0, 2);
$year=substr($timestamp, 6, 4);
// Calculations
$startday = mktime ("", "", "", $month, $day, $year); // get unix time for start date
$today = time(); // todays
$difference = $startday - $today; // work out the difference
$show = floor($difference / 86400);
--------------------------------------------------------------------------------
Lets break it down. Timestamp example 10/31/2002
$month=substr($timestamp, 0, 2); (This is taking the first 2 digits for the month.)
$day=substr($timestamp, 3, 2); (This is taking the 4th and 5th digit for the day.)
$year=substr($timestamp, 6, 4); (This is takign the 7th through 10th digits for the year.)
// Calculations
$startday = mktime ("", "", "", $month, $day, $year); // get unix time for start date
$today = time(); // todays
$difference = $startday - $today; // work out the difference
$show = floor($difference / 86400);
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you want your PHP code to be highlighted use the [syntax=php]...[/syntax] bbcode tags:
faq.php?mode=bbcode
Mac
faq.php?mode=bbcode
Mac
Code: Select all
<?php
echo "Thanks<BR>I never even noticed that Tag before.";
?>?>Posted: Mon Nov 25, 2002 1:34 am Post subject:
--------------------------------------------------------------------------------
If you want your PHP code to be highlighted use thebbcode tags:Code: Select all
...
faq.php?mode=bbcode
Mac