javascript - Check day of an ISO date - Stack Overflow

I have a date field in ISO format like this: 2017-06-06T00:00:00I'm looking for a way to find if

I have a date field in ISO format like this: 2017-06-06T00:00:00 I'm looking for a way to find if the date string above represents Saturday or Sunday. I've read some post and all of them have a Date object format date and not an ISO date. I really appreciate your help

I have a date field in ISO format like this: 2017-06-06T00:00:00 I'm looking for a way to find if the date string above represents Saturday or Sunday. I've read some post and all of them have a Date object format date and not an ISO date. I really appreciate your help

Share Improve this question asked Aug 10, 2017 at 9:06 RamAlxRamAlx 7,35424 gold badges64 silver badges110 bronze badges 3
  • I thought calling Date(string) would try to parse it using the ISO format first... is that not the case? – Jon Skeet Commented Aug 10, 2017 at 9:07
  • I've tried to parse it but it didn't return me the correct date – RamAlx Commented Aug 10, 2017 at 9:08
  • So include that information in the question - show what you've tried and what went wrong. – Jon Skeet Commented Aug 10, 2017 at 9:10
Add a ment  | 

2 Answers 2

Reset to default 4

The Date constructor accepts (a simplified version of) ISO date strings:

const date = new Date('2017-06-06T00:00:00');
const day = date.getDay();

console.log(day); // 2 = Tuesday

const date = new Date('2017-06-06T00:00:00');
const day = date.getDay();
const days = ["Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"];
console.log(days[day]);


发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745367086a4624632.html

相关推荐

  • javascript - Check day of an ISO date - Stack Overflow

    I have a date field in ISO format like this: 2017-06-06T00:00:00I'm looking for a way to find if

    9小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信