#1154

Day of the Year

pupil · 505 · lc easy +27 · verified · 49.7% accepted · 506 likes · top 37%

Description

You are given a string date in the format YYYY-MM-DD representing a Gregorian calendar date. Compute and return which numbered day of the year this date falls on.

Example 1:

Input: date = "2019-01-09"
Output: 9
Explanation: Given date is the 9th day of the year in 2019.

Example 2:

Input: date = "2019-02-10"
Output: 41

Code

1
2
3