[SOLVED] How to use php set date equate?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kennie1112
Forum Newbie
Posts: 6
Joined: Tue Oct 26, 2004 2:33 am

How to use php set date equate?

Post by kennie1112 »

Dear all,

How to use php set date equate?

e.g.
$cal_date = date("Ymd") - 14; // 14 <--- 14 Days

I think give me result is "20041014"...but it get me result is 1990...why?

I want to use today - 14days or above only...How to I do?

Who people tell me why... :cry:
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Check out http://www.php.net/date

They have good examples of all types of date formats there. :)
kennie1112
Forum Newbie
Posts: 6
Joined: Tue Oct 26, 2004 2:33 am

Post by kennie1112 »

Sorry...I already to seem it...
but I don't understand how to use this function...
Can help me how to I do...? :cry:
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

for me, the easiest is

Code: Select all

strtotime("now -14 days");
kennie1112
Forum Newbie
Posts: 6
Joined: Tue Oct 26, 2004 2:33 am

Post by kennie1112 »

I already test it...
but I don't know display result is "1097739649"
How to revert it to date format?
kennie1112
Forum Newbie
Posts: 6
Joined: Tue Oct 26, 2004 2:33 am

Post by kennie1112 »

haha...I know how to revert the date format...

e.g.
$new_date=strtotime("-14 days");
$new_date=date('Ymd',$new_date); // result: 20041014

Thank for all people to help me... :D
Post Reply