As I said in the beginning - the reason for this tutorial was because I could find no
function in PHP that was similar to ASP's DateDiff function. So after explaining how
PHP handles date and time I though it would be cool if we ported two commonly used ASP
date functions to PHP. The first one is the DateAdd function.
The DateAdd function, according the VBScript documentation I have, "Returns a date to which a specified time interval has been added."
The syntax is DateAdd (interval,number,date).
The interval is a string expression that defines the interval you want to add. For example minutes or days,
the number is the number of that interval that you wish to add,
and the date is the date.
Interval can be one of:
Day of year
Week of year
As far as I can tell, w,y and d do the same thing, that is add 1 day to the current date, q adds 3 months and ww adds 7 days. If I've missed some subtlety of VBScript, someone please let me know :)
We can save that code in a file called dateadd.inc and then execute the following code: