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;
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
add a comment |
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
Please note that there is noDate()
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
add a comment |
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
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
javascript date
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 noDate()
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
add a comment |
Please note that there is noDate()
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
add a comment |
6 Answers
6
active
oldest
votes
var now = new Date();
now.setDate(now.getDate() + 30);
add a comment |
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);
perfect! this is what i need! thanks you very much :)
– JackTurky
May 25 '12 at 18:38
add a comment |
var now = new Date();
var 30DaysLaterMonth = now.getDate() + 30;
add a comment |
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);
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
add a comment |
var d = new Date();
d.setDate(d.getDate() + 30);
add a comment |
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)
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
var now = new Date();
now.setDate(now.getDate() + 30);
add a comment |
var now = new Date();
now.setDate(now.getDate() + 30);
add a comment |
var now = new Date();
now.setDate(now.getDate() + 30);
var now = new Date();
now.setDate(now.getDate() + 30);
answered May 25 '12 at 18:32
Kenny ThompsonKenny Thompson
1,3241126
1,3241126
add a comment |
add a comment |
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);
perfect! this is what i need! thanks you very much :)
– JackTurky
May 25 '12 at 18:38
add a comment |
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);
perfect! this is what i need! thanks you very much :)
– JackTurky
May 25 '12 at 18:38
add a comment |
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);
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);
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
add a comment |
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
add a comment |
var now = new Date();
var 30DaysLaterMonth = now.getDate() + 30;
add a comment |
var now = new Date();
var 30DaysLaterMonth = now.getDate() + 30;
add a comment |
var now = new Date();
var 30DaysLaterMonth = now.getDate() + 30;
var now = new Date();
var 30DaysLaterMonth = now.getDate() + 30;
answered May 25 '12 at 18:32
Claudio RediClaudio Redi
56.9k11103132
56.9k11103132
add a comment |
add a comment |
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);
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
add a comment |
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);
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
add a comment |
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);
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);
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
add a comment |
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
add a comment |
var d = new Date();
d.setDate(d.getDate() + 30);
add a comment |
var d = new Date();
d.setDate(d.getDate() + 30);
add a comment |
var d = new Date();
d.setDate(d.getDate() + 30);
var d = new Date();
d.setDate(d.getDate() + 30);
answered May 11 '17 at 14:03
NaiveNaive
6513
6513
add a comment |
add a comment |
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)
add a comment |
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)
add a comment |
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)
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)
answered Mar 22 at 8:12
WasiFWasiF
2,9382841
2,9382841
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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