Before the meat of my reply, first the math: you'll be adding
hours because you multiplied by 60 twice. Seconds * 60 = minutes, minutes * 60 = hours.
Not to make this unintentionally complicated, but there are three different situations in which you'd use two different methods.
1. You want an amount of time measured in seconds.
A. Add seconds.
This is because the math deals with seconds too.
2. You want an amount of time measured in minutes, hours, days, or more (weeks, months, years, etc).
B. Use strtotime().
Code: Select all
$intwodays = strtotime("+2 days");
This is because there is not always 60 seconds in a minute, 3600 (60*60) seconds in an hour, or 86400 (60*60*24) seconds in a day. Generally yes, sometimes no. If you want to deal with seconds like the math requires you to do then you'd have to take into account those exceptions. Luckily PHP/the operating system can do that for you, so let it.
3. You like friendly-looking code.
B. Use strtotime() because not only will it always be 100% correct but it's quite easy to read and understand what it's doing.
The problem is that normal people don't think much about daylight savings or
leap seconds but computers have to, and if you're working with a computer then you have to too. Am I being too precise? Maybe. But did you know that June 30th, 2012 will be 86401 seconds long? Most people don't care about that difference but there are people who do. Or the more common examples: some days are 23 hours or 25 hours long (during daylight savings changes) and some years have 365 days or 366 days (during leap years).