Most efficient way to find the beginning of next month?

203 views
Skip to first unread message

Tuxlar

unread,
Dec 13, 2010, 9:10:52 AM12/13/10
to Datejs - A JavaScript Date Library
What I'm using currently is:

now.addMonths(1).set({ day:0 }).clearTime();

What could make this better?

geoffrey.mcgill

unread,
Dec 13, 2010, 11:52:04 AM12/13/10
to Datejs - A JavaScript Date Library
Hi,

I believe it would be day:1.

Example

Date.today().next().month().set({ day : 1})

Hope this helps.

Tuxlar

unread,
Dec 13, 2010, 7:54:42 PM12/13/10
to Datejs - A JavaScript Date Library
Ah yeah, I mean day:1. Does setting to the next month bring it to the
beginning of that month?

RobG

unread,
Dec 22, 2010, 6:19:03 AM12/22/10
to Datejs - A JavaScript Date Library
var d = new Date();
d.setMonth(d.getMonth() + 1, 1);
d.setHours(0,0,0);


--
Rob

Diana chow

unread,
Mar 2, 2011, 2:24:14 PM3/2/11
to dat...@googlegroups.com
I find this to be pretty clear: 

Date.parse('next month').moveToFirstDayOfMonth();
Reply all
Reply to author
Forward
0 new messages