www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Add a month to a strftime('%x') date

  1. #1
    Join Date
    Aug 2009
    Posts
    53

    resolved [RESOLVED] Add a month to a strftime('%x') date

    I have a date('d/m/y') date added to a MySQL database & then gotten & displayed on a page. How do I get the same date from the MySQL database (displayed as dd/mm/YY) & add 1 month.

    Any help would be appreciated.
    Last edited by mattwidge; 10-24-2009 at 07:39 PM.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,174
    You could add it as another field to select from your query:
    Code:
    SELECT `date_col`, `date_col` + INTERVAL 1 MONTH AS `next_month` FROM . . .
    Alternatively, if you've converted the query result into a UNIX timestamp integer in your code:
    PHP Code:
    $nextMonth strtotime('+1 month'$timestampValueFromDB); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Aug 2009
    Posts
    53
    I've found a way that instead of displaying a month from a certain date, it shows the last day of the month instead. This suits my needs fine.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles