Master:
# 1    php calculate number of days between two dates                  
Dude
Online no
State
Grouping Member
Class class4
Score 143
Wealth 116.5
Posts 99
Login 00:58:28
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: 296, Date: 2010-01-16 02:34:07
[Agree] ( 4 ) [Against] ( 3 )

# 2    is the return value of strtotime() timestamp?                  
linlin
Online no
State
Grouping Member
Class class3
Score 76
Wealth 83
Posts 47
Login 23:31:38
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: 294, Date: 2010-01-16 02:38:52
[Agree] ( 4 ) [Against] ( 3 )

# 3    floor( ) round fraction down                  
luke1
Online no
State 453
Grouping Super Admin
Class class4
Score 229
Wealth 51.5
Posts 213
Login 05:38:22
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: 292, Date: 2010-01-16 02:45:34
[Agree] ( 4 ) [Against] ( 3 )

# 4    regarding number and data type, i got another question                  
linlin
Online no
State
Grouping Member
Class class3
Score 76
Wealth 83
Posts 47
Login 23:31:38
what is the different between float and double?
I found the data types in mysql database design.
Hits: 290, Date: 2010-01-16 02:51:27
[Agree] ( 4 ) [Against] ( 3 )

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