How to calculate the date 30 days from today Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag?How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I redirect to another webpage?How do I get the current date in JavaScript?How to check whether a string contains a substring in JavaScript?How to decide when to use Node.js?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

How do I keep my slimes from escaping their pens?

Why are there no cargo aircraft with "flying wing" design?

Sorting numerically

What LEGO pieces have "real-world" functionality?

How do I determine if the rules for a long jump or high jump are applicable for Monks?

What causes the vertical darker bands in my photo?

What do you call a plan that's an alternative plan in case your initial plan fails?

Why does Python start at index 1 when iterating an array backwards?

Bonus calculation: Am I making a mountain out of a molehill?

Storing hydrofluoric acid before the invention of plastics

Should gear shift center itself while in neutral?

How can whole tone melodies sound more interesting?

List *all* the tuples!

How can I fade player when goes inside or outside of the area?

Output the ŋarâþ crîþ alphabet song without using (m)any letters

Gastric acid as a weapon

What would be the ideal power source for a cybernetic eye?

Antler Helmet: Can it work?

Examples of mediopassive verb constructions

Is 1 ppb equal to 1 μg/kg?

What are the pros and cons of Aerospike nosecones?

Can a non-EU citizen traveling with me come with me through the EU passport line?

What is a Meta algorithm?



How to calculate the date 30 days from today



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I redirect to another webpage?How do I get the current date in JavaScript?How to check whether a string contains a substring in JavaScript?How to decide when to use Node.js?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








5















i need to calculate the date from thirty days using Date in javascript



var now = new Date();


Example:



if today is the 13 February 2013, 30 days later is the 15 March 2013. so something that is different from 30DaysLaterMonth = ActualMonth+1.



I hope my question is clear.. :)
thanks everybody!










share|improve this question
























  • Please note that there is no Date() in jQuery. What you are talking about is Javascript.

    – kapa
    May 25 '12 at 18:31











  • updated! thanks :)

    – JackTurky
    May 25 '12 at 18:31

















5















i need to calculate the date from thirty days using Date in javascript



var now = new Date();


Example:



if today is the 13 February 2013, 30 days later is the 15 March 2013. so something that is different from 30DaysLaterMonth = ActualMonth+1.



I hope my question is clear.. :)
thanks everybody!










share|improve this question
























  • Please note that there is no Date() in jQuery. What you are talking about is Javascript.

    – kapa
    May 25 '12 at 18:31











  • updated! thanks :)

    – JackTurky
    May 25 '12 at 18:31













5












5








5








i need to calculate the date from thirty days using Date in javascript



var now = new Date();


Example:



if today is the 13 February 2013, 30 days later is the 15 March 2013. so something that is different from 30DaysLaterMonth = ActualMonth+1.



I hope my question is clear.. :)
thanks everybody!










share|improve this question
















i need to calculate the date from thirty days using Date in javascript



var now = new Date();


Example:



if today is the 13 February 2013, 30 days later is the 15 March 2013. so something that is different from 30DaysLaterMonth = ActualMonth+1.



I hope my question is clear.. :)
thanks everybody!







javascript date






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 1 '15 at 13:06









Darren Sweeney

11.4k2681154




11.4k2681154










asked May 25 '12 at 18:29









JackTurkyJackTurky

7,95936116191




7,95936116191












  • Please note that there is no Date() in jQuery. What you are talking about is Javascript.

    – kapa
    May 25 '12 at 18:31











  • updated! thanks :)

    – JackTurky
    May 25 '12 at 18:31

















  • Please note that there is no Date() in jQuery. What you are talking about is Javascript.

    – kapa
    May 25 '12 at 18:31











  • updated! thanks :)

    – JackTurky
    May 25 '12 at 18:31
















Please note that there is no Date() in jQuery. What you are talking about is Javascript.

– kapa
May 25 '12 at 18:31





Please note that there is no Date() in jQuery. What you are talking about is Javascript.

– kapa
May 25 '12 at 18:31













updated! thanks :)

– JackTurky
May 25 '12 at 18:31





updated! thanks :)

– JackTurky
May 25 '12 at 18:31












6 Answers
6






active

oldest

votes


















8














var now = new Date(); 
now.setDate(now.getDate() + 30);





share|improve this answer






























    9














    I think its better for you to use Datejs




    Datejs is an open-source JavaScript Date Library.




    or you can do it own:



    var cur = new Date(),
    after30days = cur.setDate(cur.getDate() + 30);





    share|improve this answer

























    • perfect! this is what i need! thanks you very much :)

      – JackTurky
      May 25 '12 at 18:38


















    4














    var now = new Date();
    var 30DaysLaterMonth = now.getDate() + 30;





    share|improve this answer






























      0














      In native javascript, use Date.UTC(year, month, day)to get the number of milliseconds from 1971-01-01. Than add days * (86400000) and create date from this value:



      var date_one_ms = Date.UTC(2012, 05, 25);
      var ms_in_day = 24*3600*1000; // 86400000;
      var date_30_days_later = new Date(date_one_ms + 30 * ms_in_day);





      share|improve this answer























      • i think this is the more complex solution.. see the accepted answer to see what library opensource can do :)

        – JackTurky
        May 25 '12 at 18:54






      • 1





        I agree, the solution is more complex that te accepted one. Anyway, it reveals the inner working of a Date object and is usefull if you want to do date calculation based on other time slices like weeks or hours.

        – Aleš Kotnik
        May 25 '12 at 18:56











      • BTW You don't need Datejs for the accepted solution to work. It works in plain javascript.

        – Aleš Kotnik
        May 25 '12 at 19:00











      • i know.. but i prefer jquery :)

        – JackTurky
        May 26 '12 at 0:11


















      0














      var d = new Date();
      d.setDate(d.getDate() + 30);





      share|improve this answer






























        0














        Get last 30 days form today






        let now = new Date()
        console.log(now)
        let last30days = new Date(now.setDate(now.getDate() - 30))
        console.log(last30days)





        Get next 30 days from today






        let now = new Date()
        console.log(now)
        let next30days = new Date(now.setDate(now.getDate() + 30))
        console.log(next30days)








        share|improve this answer























          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10759647%2fhow-to-calculate-the-date-30-days-from-today%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          6 Answers
          6






          active

          oldest

          votes








          6 Answers
          6






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8














          var now = new Date(); 
          now.setDate(now.getDate() + 30);





          share|improve this answer



























            8














            var now = new Date(); 
            now.setDate(now.getDate() + 30);





            share|improve this answer

























              8












              8








              8







              var now = new Date(); 
              now.setDate(now.getDate() + 30);





              share|improve this answer













              var now = new Date(); 
              now.setDate(now.getDate() + 30);






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 25 '12 at 18:32









              Kenny ThompsonKenny Thompson

              1,3241126




              1,3241126























                  9














                  I think its better for you to use Datejs




                  Datejs is an open-source JavaScript Date Library.




                  or you can do it own:



                  var cur = new Date(),
                  after30days = cur.setDate(cur.getDate() + 30);





                  share|improve this answer

























                  • perfect! this is what i need! thanks you very much :)

                    – JackTurky
                    May 25 '12 at 18:38















                  9














                  I think its better for you to use Datejs




                  Datejs is an open-source JavaScript Date Library.




                  or you can do it own:



                  var cur = new Date(),
                  after30days = cur.setDate(cur.getDate() + 30);





                  share|improve this answer

























                  • perfect! this is what i need! thanks you very much :)

                    – JackTurky
                    May 25 '12 at 18:38













                  9












                  9








                  9







                  I think its better for you to use Datejs




                  Datejs is an open-source JavaScript Date Library.




                  or you can do it own:



                  var cur = new Date(),
                  after30days = cur.setDate(cur.getDate() + 30);





                  share|improve this answer















                  I think its better for you to use Datejs




                  Datejs is an open-source JavaScript Date Library.




                  or you can do it own:



                  var cur = new Date(),
                  after30days = cur.setDate(cur.getDate() + 30);






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 25 '12 at 18:35

























                  answered May 25 '12 at 18:30









                  thecodeparadoxthecodeparadox

                  71.6k18123155




                  71.6k18123155












                  • perfect! this is what i need! thanks you very much :)

                    – JackTurky
                    May 25 '12 at 18:38

















                  • perfect! this is what i need! thanks you very much :)

                    – JackTurky
                    May 25 '12 at 18:38
















                  perfect! this is what i need! thanks you very much :)

                  – JackTurky
                  May 25 '12 at 18:38





                  perfect! this is what i need! thanks you very much :)

                  – JackTurky
                  May 25 '12 at 18:38











                  4














                  var now = new Date();
                  var 30DaysLaterMonth = now.getDate() + 30;





                  share|improve this answer



























                    4














                    var now = new Date();
                    var 30DaysLaterMonth = now.getDate() + 30;





                    share|improve this answer

























                      4












                      4








                      4







                      var now = new Date();
                      var 30DaysLaterMonth = now.getDate() + 30;





                      share|improve this answer













                      var now = new Date();
                      var 30DaysLaterMonth = now.getDate() + 30;






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 25 '12 at 18:32









                      Claudio RediClaudio Redi

                      56.9k11103132




                      56.9k11103132





















                          0














                          In native javascript, use Date.UTC(year, month, day)to get the number of milliseconds from 1971-01-01. Than add days * (86400000) and create date from this value:



                          var date_one_ms = Date.UTC(2012, 05, 25);
                          var ms_in_day = 24*3600*1000; // 86400000;
                          var date_30_days_later = new Date(date_one_ms + 30 * ms_in_day);





                          share|improve this answer























                          • i think this is the more complex solution.. see the accepted answer to see what library opensource can do :)

                            – JackTurky
                            May 25 '12 at 18:54






                          • 1





                            I agree, the solution is more complex that te accepted one. Anyway, it reveals the inner working of a Date object and is usefull if you want to do date calculation based on other time slices like weeks or hours.

                            – Aleš Kotnik
                            May 25 '12 at 18:56











                          • BTW You don't need Datejs for the accepted solution to work. It works in plain javascript.

                            – Aleš Kotnik
                            May 25 '12 at 19:00











                          • i know.. but i prefer jquery :)

                            – JackTurky
                            May 26 '12 at 0:11















                          0














                          In native javascript, use Date.UTC(year, month, day)to get the number of milliseconds from 1971-01-01. Than add days * (86400000) and create date from this value:



                          var date_one_ms = Date.UTC(2012, 05, 25);
                          var ms_in_day = 24*3600*1000; // 86400000;
                          var date_30_days_later = new Date(date_one_ms + 30 * ms_in_day);





                          share|improve this answer























                          • i think this is the more complex solution.. see the accepted answer to see what library opensource can do :)

                            – JackTurky
                            May 25 '12 at 18:54






                          • 1





                            I agree, the solution is more complex that te accepted one. Anyway, it reveals the inner working of a Date object and is usefull if you want to do date calculation based on other time slices like weeks or hours.

                            – Aleš Kotnik
                            May 25 '12 at 18:56











                          • BTW You don't need Datejs for the accepted solution to work. It works in plain javascript.

                            – Aleš Kotnik
                            May 25 '12 at 19:00











                          • i know.. but i prefer jquery :)

                            – JackTurky
                            May 26 '12 at 0:11













                          0












                          0








                          0







                          In native javascript, use Date.UTC(year, month, day)to get the number of milliseconds from 1971-01-01. Than add days * (86400000) and create date from this value:



                          var date_one_ms = Date.UTC(2012, 05, 25);
                          var ms_in_day = 24*3600*1000; // 86400000;
                          var date_30_days_later = new Date(date_one_ms + 30 * ms_in_day);





                          share|improve this answer













                          In native javascript, use Date.UTC(year, month, day)to get the number of milliseconds from 1971-01-01. Than add days * (86400000) and create date from this value:



                          var date_one_ms = Date.UTC(2012, 05, 25);
                          var ms_in_day = 24*3600*1000; // 86400000;
                          var date_30_days_later = new Date(date_one_ms + 30 * ms_in_day);






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered May 25 '12 at 18:47









                          Aleš KotnikAleš Kotnik

                          2,2241416




                          2,2241416












                          • i think this is the more complex solution.. see the accepted answer to see what library opensource can do :)

                            – JackTurky
                            May 25 '12 at 18:54






                          • 1





                            I agree, the solution is more complex that te accepted one. Anyway, it reveals the inner working of a Date object and is usefull if you want to do date calculation based on other time slices like weeks or hours.

                            – Aleš Kotnik
                            May 25 '12 at 18:56











                          • BTW You don't need Datejs for the accepted solution to work. It works in plain javascript.

                            – Aleš Kotnik
                            May 25 '12 at 19:00











                          • i know.. but i prefer jquery :)

                            – JackTurky
                            May 26 '12 at 0:11

















                          • i think this is the more complex solution.. see the accepted answer to see what library opensource can do :)

                            – JackTurky
                            May 25 '12 at 18:54






                          • 1





                            I agree, the solution is more complex that te accepted one. Anyway, it reveals the inner working of a Date object and is usefull if you want to do date calculation based on other time slices like weeks or hours.

                            – Aleš Kotnik
                            May 25 '12 at 18:56











                          • BTW You don't need Datejs for the accepted solution to work. It works in plain javascript.

                            – Aleš Kotnik
                            May 25 '12 at 19:00











                          • i know.. but i prefer jquery :)

                            – JackTurky
                            May 26 '12 at 0:11
















                          i think this is the more complex solution.. see the accepted answer to see what library opensource can do :)

                          – JackTurky
                          May 25 '12 at 18:54





                          i think this is the more complex solution.. see the accepted answer to see what library opensource can do :)

                          – JackTurky
                          May 25 '12 at 18:54




                          1




                          1





                          I agree, the solution is more complex that te accepted one. Anyway, it reveals the inner working of a Date object and is usefull if you want to do date calculation based on other time slices like weeks or hours.

                          – Aleš Kotnik
                          May 25 '12 at 18:56





                          I agree, the solution is more complex that te accepted one. Anyway, it reveals the inner working of a Date object and is usefull if you want to do date calculation based on other time slices like weeks or hours.

                          – Aleš Kotnik
                          May 25 '12 at 18:56













                          BTW You don't need Datejs for the accepted solution to work. It works in plain javascript.

                          – Aleš Kotnik
                          May 25 '12 at 19:00





                          BTW You don't need Datejs for the accepted solution to work. It works in plain javascript.

                          – Aleš Kotnik
                          May 25 '12 at 19:00













                          i know.. but i prefer jquery :)

                          – JackTurky
                          May 26 '12 at 0:11





                          i know.. but i prefer jquery :)

                          – JackTurky
                          May 26 '12 at 0:11











                          0














                          var d = new Date();
                          d.setDate(d.getDate() + 30);





                          share|improve this answer



























                            0














                            var d = new Date();
                            d.setDate(d.getDate() + 30);





                            share|improve this answer

























                              0












                              0








                              0







                              var d = new Date();
                              d.setDate(d.getDate() + 30);





                              share|improve this answer













                              var d = new Date();
                              d.setDate(d.getDate() + 30);






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 11 '17 at 14:03









                              NaiveNaive

                              6513




                              6513





















                                  0














                                  Get last 30 days form today






                                  let now = new Date()
                                  console.log(now)
                                  let last30days = new Date(now.setDate(now.getDate() - 30))
                                  console.log(last30days)





                                  Get next 30 days from today






                                  let now = new Date()
                                  console.log(now)
                                  let next30days = new Date(now.setDate(now.getDate() + 30))
                                  console.log(next30days)








                                  share|improve this answer



























                                    0














                                    Get last 30 days form today






                                    let now = new Date()
                                    console.log(now)
                                    let last30days = new Date(now.setDate(now.getDate() - 30))
                                    console.log(last30days)





                                    Get next 30 days from today






                                    let now = new Date()
                                    console.log(now)
                                    let next30days = new Date(now.setDate(now.getDate() + 30))
                                    console.log(next30days)








                                    share|improve this answer

























                                      0












                                      0








                                      0







                                      Get last 30 days form today






                                      let now = new Date()
                                      console.log(now)
                                      let last30days = new Date(now.setDate(now.getDate() - 30))
                                      console.log(last30days)





                                      Get next 30 days from today






                                      let now = new Date()
                                      console.log(now)
                                      let next30days = new Date(now.setDate(now.getDate() + 30))
                                      console.log(next30days)








                                      share|improve this answer













                                      Get last 30 days form today






                                      let now = new Date()
                                      console.log(now)
                                      let last30days = new Date(now.setDate(now.getDate() - 30))
                                      console.log(last30days)





                                      Get next 30 days from today






                                      let now = new Date()
                                      console.log(now)
                                      let next30days = new Date(now.setDate(now.getDate() + 30))
                                      console.log(next30days)








                                      let now = new Date()
                                      console.log(now)
                                      let last30days = new Date(now.setDate(now.getDate() - 30))
                                      console.log(last30days)





                                      let now = new Date()
                                      console.log(now)
                                      let last30days = new Date(now.setDate(now.getDate() - 30))
                                      console.log(last30days)





                                      let now = new Date()
                                      console.log(now)
                                      let next30days = new Date(now.setDate(now.getDate() + 30))
                                      console.log(next30days)





                                      let now = new Date()
                                      console.log(now)
                                      let next30days = new Date(now.setDate(now.getDate() + 30))
                                      console.log(next30days)






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Mar 22 at 8:12









                                      WasiFWasiF

                                      2,9382841




                                      2,9382841



























                                          draft saved

                                          draft discarded
















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid


                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.

                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10759647%2fhow-to-calculate-the-date-30-days-from-today%23new-answer', 'question_page');

                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현