Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date functions

Status
Not open for further replies.

digiduck

Programmer
Apr 4, 2003
95
US
first off I've never used PHP before, I'm an ASP/.NET guy :) but on this particular project I have to write a script in PHP and I need help...

I need to take a date like "5/12/2003" and subtract it from todays date to get the numbers of days returned. The reason is I need to find out if certian periods of time have passed, like 1 day, 7 days, 14 days...

Can someone please post some code that I can use? Or point me in the right direction to some examples. I'd appreciate it.

Gone looking for myself. Should I arrive before I'm back, keep me here.
 
convert the date value to a timestamp, get the current timestamp and compare the two values. timestamps are recorded in number of seconds, so if you divide by 86400 you get the number of days.

the function you need is mktime() - you can look up the syntax at:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top