D3.js | d3.utcDay() Function
Last Updated :
24 Jul, 2019
The d3.utcDay() function in D3.js is used to return date in “YYYY-MM-DD” format in Coordinated Universal Time (UTC).
Syntax:
d3.utcDay(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.utcDay() function in D3.js:
Example 1:
<!DOCTYPE html>
<html>
<head>
<script src=
</script>
</head>
<body>
<script>
var now = new Date;
var day = d3.utcDay(now);
console.log(day);
</script>
</body>
</html>
|
Output:
"2019-07-20T00:00:00.000Z"
Example 2: Below code calculates the difference between two given dates.
<!DOCTYPE html>
<html>
<head>
<script src=
</script>
</head>
<body>
<script>
var start = new Date(2015, 02, 01);
var end = new Date(2015, 02, 04);
var a = d3.utcDay.count(start, end);
console.log(a);
</script>
</body>
</html>
|
Output:
3
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...