Results 1 to 3 of 3

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

  1. #1
    Join Date
    Aug 2009

    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 08:39 PM.

  2. #2
    Join Date
    Aug 2004
    You could add it as another field to select from your query:
    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); 
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Aug 2009
    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