簡體   English   中英

使用年中的年和日數獲取日期

[英]get the date by using the year and day number in the year

我有一個函數,我將那一年的年份和日期作為參數,我需要返回日期。 我曾嘗試使用 momentjs 但無法獲取正確的結果。 假設 getDate(2019,1) 應該返回Jan 1, 20191st Jan 2019日期格式無關緊要。 很感謝任何形式的幫助。

請查看mometJs庫。 給出了多個例子。

如果你還沒有實現 momentJs,我建議你看看day.Js,它比 momentJs 輕得多。

使用 momentjs 是個好主意。

function getDate(year, dayOfYear) {
    return moment().dayOfYear(dayOfYear).year(year)
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM