D3.js: Remove leading zero from time format
In D3.js, all time format directives are zero-padded by default (except for %e
which explicitly uses space-padding).
For example, using d3.timeFormat("%I:%M")
will output 09:34
.
To change the padding type, append a modifier to the directive’s %
:
-
0
to use zero-padding -
_
to use space-padding -
-
to disable padding altogether
Following the above example, using d3.timeFormat("%-I:%M")
will yield 9:34
.