Master:
# 1 php calculate number of days between two dates                  
Dude
Online no
State
Grouping Member
Class class3
Score 78
Wealth 84
Posts 44
Login 03-07 04:39:11
I have a simple idea to calculate number of days between two dates:
$date1 = "2010-01-12";
$date2 = "2009-01-12";

$days = floor(strtotime($date1)-strtotime($date2)/3600/24);

Hope this helps.
Hits: 49, Date: 2010-01-16 02:34:07
[Agree] ( 1 ) [Against] ( 1 )

# 2 is the return value of strtotime() timestamp?                  
linlin
Online no
State
Grouping Member
Class class3
Score 58
Wealth 74
Posts 32
Login 03-09 07:27:24
the 3600 should be the seconds of one hour, 24 should be the hours of one day, then the different between the timestamp diveded by 3600 and 24, should be the number of days.

What happen if we use round() instead of floor()?

Hits: 47, Date: 2010-01-16 02:38:52
[Agree] ( 1 ) [Against] ( 1 )

# 3 floor( ) round fraction down                  
luke1
Online no
State 453
Grouping Super Admin
Class class4
Score 123
Wealth 26.5
Posts 116
Login 03-06 05:51:37
ceil() round fraction up

round(), round the number less than 0.5 down, round the number larger than 0.5 up.

so, in this case, i believe all of floor(), round() and ceil() can be used.
Hits: 45, Date: 2010-01-16 02:45:34
[Agree] ( 1 ) [Against] ( 1 )

# 4 regarding number and data type, i got another question                  
linlin
Online no
State
Grouping Member
Class class3
Score 58
Wealth 74
Posts 32
Login 03-09 07:27:24
what is the different between float and double?
I found the data types in mysql database design.
Hits: 43, Date: 2010-01-16 02:51:27
[Agree] ( 1 ) [Against] ( 1 )

1 - 4 [ 4]

Reply: php calculate number of days between two dates

*First line:


More content:


Tags:



Hint: You cannot post here before loginLogin | Register

nothing