And for some reason i cant seem to do it lol, any help would be great
Having a hard time with some date logic, please help :(
Moderator: General Moderators
Having a hard time with some date logic, please help :(
All I want to do is get a date 3 days before todays date, in a ymd format.
And for some reason i cant seem to do it lol, any help would be great
And for some reason i cant seem to do it lol, any help would be great
date 3 days before
Code: Select all
$three_days_ago = date("ymd",mktime(1,1,1,date(m),date(d)-3,date(y)));Here is the manual page: http://www.php.net/manual/en/function.mktime.php
Hope that helps
http://www.php.net/manual/en/function.date.php has some examples.
A simple approach isbut I likealthough you loose hours,minutes,... (can be fixed anyway).
If you're using a database to check some date/times check wether it has date-functions to perform this, e.g.is valid for mySql.
A simple approach is
Code: Select all
$threeDays = 3 * 86400 // 3 days, each having 60*60*24 seconds
$theDate = time() - $threeDays;Code: Select all
$theDate = mktime (0,0,0,date("m") ,date("d")-3,date("Y"));If you're using a database to check some date/times check wether it has date-functions to perform this, e.g.
Code: Select all
SELECT Now()-Interval 3 day