sammy sammy - 4 months ago 7
Javascript Question

how to remove zero if hours less then 10 from d3.time.format("%I %p")

I am very new to d3.js. I am using

d3.time.format("%I %p")
which returns hours with a zero appended with single digit.

For example
new Date(1985,11,1,5,39,13)
returns
05
. How to make it return a single digit if hour is less than
10
?

Answer

Simply write a minus sign before I:

d3.time.format("%-I %p");
Comments