Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. PHP add date (easy one hopefully!)

PHP add date (easy one hopefully!)

Scheduled Pinned Locked Moved Web Development
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    harveyhanson
    wrote on last edited by
    #1

    In Dreamweaver MX (phpcode) Hi, Im trying to put a date in a text box that has +14days from the current date, how would you do this. Is it something like "date()+14" I cant get it working!!!!

    B 1 Reply Last reply
    0
    • H harveyhanson

      In Dreamweaver MX (phpcode) Hi, Im trying to put a date in a text box that has +14days from the current date, how would you do this. Is it something like "date()+14" I cant get it working!!!!

      B Offline
      B Offline
      Bradml
      wrote on last edited by
      #2

      The PHP mktime function is what you want: Linkety[^]

      $todayArray = explode("-", date("M-d-Y"));
      $future = date("M-d-Y", mktime(0, 0, 0, $todayArray[0], ``` `$todayArray[1]+140``,` ``` `$todayArray[2]``));`


      Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.

      H 1 Reply Last reply
      0
      • B Bradml

        The PHP mktime function is what you want: Linkety[^]

        $todayArray = explode("-", date("M-d-Y"));
        $future = date("M-d-Y", mktime(0, 0, 0, $todayArray[0], ``` `$todayArray[1]+140``,` ``` `$todayArray[2]``));`


        Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.

        H Offline
        H Offline
        harveyhanson
        wrote on last edited by
        #3

        But where do i put this in the code? I have tried to insert this code in the initial value box and it still doesnt work... grrrr!!!

        L B 2 Replies Last reply
        0
        • H harveyhanson

          But where do i put this in the code? I have tried to insert this code in the initial value box and it still doesnt work... grrrr!!!

          L Offline
          L Offline
          l a u r e n
          wrote on last edited by
          #4

          ok this depends exactly what you want to do with the value you get also brad does your solution take into account month and year (and leap year) rollovers?

          "there is no spoon" {me}

          B 1 Reply Last reply
          0
          • H harveyhanson

            But where do i put this in the code? I have tried to insert this code in the initial value box and it still doesnt work... grrrr!!!

            B Offline
            B Offline
            Bradml
            wrote on last edited by
            #5

            Please enil me the code you are using


            Brad Australian - Bradml on "MVP Status" If this was posted in a programming board please rate my answer

            1 Reply Last reply
            0
            • L l a u r e n

              ok this depends exactly what you want to do with the value you get also brad does your solution take into account month and year (and leap year) rollovers?

              "there is no spoon" {me}

              B Offline
              B Offline
              Bradml
              wrote on last edited by
              #6

              PHP date functions handle all that for you.


              Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups