Get the local date instead of UTC

前端 未结 2 1292
野性不改
野性不改 2021-01-26 18:01

The following script calculates me next Friday and next Sunday date.

The problem : the use of .toISOString uses UTC time. I need to change with somethin

2条回答
  •  醉话见心
    2021-01-26 18:36

    You are concerned that the [yyyy,mm,dd] is in UTC and not in current timzone?

    The nextFriday is a date object. Would it work if you use the get-functions instead? e.g.

    const nextFridayYear = nextFriday.getFullYear();
    // get month is zero index based, i have added one
    const nextFridayMonth = (nextFriday.getMonth() + 1).toString()
        .padStart(2, '0');
    const nextFridayDay = today.getDate().toString()
        .padStart(2, '0');
    

提交回复
热议问题