Timestamp intervals in JavaScript

Multi tool use
up vote
2
down vote
favorite
How can I pick a past date that is a Tuesday or Monday, then get timestamps at 2 week intervals in JavaScript? I am using faker.js. I can only get a date in the past in years, 2 and 1 as shown below.
const releaseStart1 = new Date(faker.date.past(2, new Date(Date.now())));
const releaseEnd1 = new Date(faker.date.past(1, new Date(Date.now())));
javascript datetime unix-timestamp faker
add a comment |
up vote
2
down vote
favorite
How can I pick a past date that is a Tuesday or Monday, then get timestamps at 2 week intervals in JavaScript? I am using faker.js. I can only get a date in the past in years, 2 and 1 as shown below.
const releaseStart1 = new Date(faker.date.past(2, new Date(Date.now())));
const releaseEnd1 = new Date(faker.date.past(1, new Date(Date.now())));
javascript datetime unix-timestamp faker
What is the reason you would use faker for that?
– str
Nov 9 at 14:16
Good point. It was the only way I knew of to get dates in the past. It would actually be better, if i could pick a Tuesday 3, 5, or however many months ago specifically.
– Matthew Divertie
Nov 9 at 14:25
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
How can I pick a past date that is a Tuesday or Monday, then get timestamps at 2 week intervals in JavaScript? I am using faker.js. I can only get a date in the past in years, 2 and 1 as shown below.
const releaseStart1 = new Date(faker.date.past(2, new Date(Date.now())));
const releaseEnd1 = new Date(faker.date.past(1, new Date(Date.now())));
javascript datetime unix-timestamp faker
How can I pick a past date that is a Tuesday or Monday, then get timestamps at 2 week intervals in JavaScript? I am using faker.js. I can only get a date in the past in years, 2 and 1 as shown below.
const releaseStart1 = new Date(faker.date.past(2, new Date(Date.now())));
const releaseEnd1 = new Date(faker.date.past(1, new Date(Date.now())));
javascript datetime unix-timestamp faker
javascript datetime unix-timestamp faker
asked Nov 9 at 14:07
Matthew Divertie
324
324
What is the reason you would use faker for that?
– str
Nov 9 at 14:16
Good point. It was the only way I knew of to get dates in the past. It would actually be better, if i could pick a Tuesday 3, 5, or however many months ago specifically.
– Matthew Divertie
Nov 9 at 14:25
add a comment |
What is the reason you would use faker for that?
– str
Nov 9 at 14:16
Good point. It was the only way I knew of to get dates in the past. It would actually be better, if i could pick a Tuesday 3, 5, or however many months ago specifically.
– Matthew Divertie
Nov 9 at 14:25
What is the reason you would use faker for that?
– str
Nov 9 at 14:16
What is the reason you would use faker for that?
– str
Nov 9 at 14:16
Good point. It was the only way I knew of to get dates in the past. It would actually be better, if i could pick a Tuesday 3, 5, or however many months ago specifically.
– Matthew Divertie
Nov 9 at 14:25
Good point. It was the only way I knew of to get dates in the past. It would actually be better, if i could pick a Tuesday 3, 5, or however many months ago specifically.
– Matthew Divertie
Nov 9 at 14:25
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Look at using moment as it will let you do something like
let date = moment().subtract(7, 'days').format();
Which will return the date. You can use days
weeks
months
seconds
minutes
hours
etc
https://momentjs.com/docs/
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Look at using moment as it will let you do something like
let date = moment().subtract(7, 'days').format();
Which will return the date. You can use days
weeks
months
seconds
minutes
hours
etc
https://momentjs.com/docs/
add a comment |
up vote
1
down vote
accepted
Look at using moment as it will let you do something like
let date = moment().subtract(7, 'days').format();
Which will return the date. You can use days
weeks
months
seconds
minutes
hours
etc
https://momentjs.com/docs/
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Look at using moment as it will let you do something like
let date = moment().subtract(7, 'days').format();
Which will return the date. You can use days
weeks
months
seconds
minutes
hours
etc
https://momentjs.com/docs/
Look at using moment as it will let you do something like
let date = moment().subtract(7, 'days').format();
Which will return the date. You can use days
weeks
months
seconds
minutes
hours
etc
https://momentjs.com/docs/
edited Nov 9 at 14:35
answered Nov 9 at 14:29


Noel Kriegler
301110
301110
add a comment |
add a comment |
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53227276%2ftimestamp-intervals-in-javascript%23new-answer', 'question_page');
);
Post as a guest
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
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
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
vAhfz2DcvWhLK0,F48gzz0wz,m ALfGgqru3D0zqfLMO8 Z3iGWVQOSHf,kZdxS b6,j,ZbsksmDf
What is the reason you would use faker for that?
– str
Nov 9 at 14:16
Good point. It was the only way I knew of to get dates in the past. It would actually be better, if i could pick a Tuesday 3, 5, or however many months ago specifically.
– Matthew Divertie
Nov 9 at 14:25