Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-13-2008, 07:35 PM   PM User | #1
RyanB88
Regular Coder

 
Join Date: Mar 2005
Location: Spokane, WA
Posts: 146
Thanks: 4
Thanked 3 Times in 3 Posts
RyanB88 is an unknown quantity at this point
Adding 90 days, and comparing dates

I am writing a small script and I have two simular date related questions.

1) I have stored in a DB a date such as 12/13/2008, but the date stored could be any previous date, not just todays date, what I need to do is add 90 days to the date and echo that to the user

2) I would like to compare today's date with the value generated in question 1 to determain if today is the date generated or before, or after, then depending on that set a boolean that I would use to either show an message to the user or not.
RyanB88 is offline   Reply With Quote
Old 12-13-2008, 08:06 PM   PM User | #2
PappaJohn
Senior Coder

 
Join Date: Apr 2007
Location: Quakertown PA USA
Posts: 1,028
Thanks: 1
Thanked 125 Times in 123 Posts
PappaJohn will become famous soon enough
MySQL provides a number of Date and Time functions that will do what you want.

For example, for #1, you can look into DATE_ADD()
PappaJohn is offline   Reply With Quote
Old 12-14-2008, 12:19 PM   PM User | #3
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
1) I have stored in a DB a date such as 12/13/2008, but the date stored could be any previous date, not just todays date, what I need to do is add 90 days to the date and echo that to the user
Take some effort to change them to the datetime format. All your other operations will be simplified then!
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Tags
comparing, date, manipulation, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:38 PM.


Advertisement
Log in to turn off these ads.