PHP Date Calculation

Peter

Member
Joined
Jul 7, 2012
Messages
59
Points
0
Hello,

How can we know the number of days between two given dates using php?
You can use this to get number of days between startdate and enddate
Code:
<?php
$startDate = strtotime('2013-10-02');
$endDate = strtotime('2013-12-02');
$number_of_days = ($endDate - $startDate) / (60 * 60 * 24);
echo $number_of_days;
?>
Hope it's useful for you.
 

Adriana14

Member
Joined
Apr 21, 2014
Messages
21
Points
0
Use for exemple
$timestamp1 = strtotime('22-09-2008');
$timestamp2 = strtotime('27-12-2008');
$res = $timestamp2 - $timestamp1
$date = date('m/d/Y', $ras);
 
Older Threads
Replies
2
Views
5,020
Replies
0
Views
1,818
Replies
3
Views
2,522
Replies
7
Views
4,390
Latest Threads
Replies
1
Views
56
Replies
0
Views
47
Replies
0
Views
66
Recommended Threads
Replies
27
Views
9,418
Replies
0
Views
1,572
Replies
4
Views
1,621
Replies
5
Views
3,571

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top