D3.js | d3.timeDay() Function

The d3.timeDay() function in D3.js is used to return date in “YYYY-MM-DD” format.
Syntax:
d3.timeDay(Date);
Parameters: This function accepts a parameter “Date”.
Return Value: This function returns the given date in a specific format.
Below programs illustrate the d3.timeDay() function in D3.js:
Example 1: 
| <!DOCTYPE html> <html>  <head>     <script src=   </script> </head>  <body>      <script>         // Initialising a current date         varnow = newDate;          // calling d3.timeDay()         varday = d3.timeDay(now);          // Getting the date         console.log(day);     </script> </body>  </html>  | 
Output:
"2019-07-19T18:30:00.000Z"
Example 2: Below code calculates the difference between two given dates.
| <!DOCTYPE html> <html>  <head>     <script src=   </script> </head>  <body>      <script>         // Initialising start and end date         varstart = newDate(2015, 02, 01);         varend = newDate(2015, 02, 04);          // Calling the timeDay() function to         // calculate the difference between two dates         vara = d3.timeDay.count(start, end);          // Getting the calculated dates         console.log(a);     </script> </body>  </html>  | 
Output:
3
 
				 
					


