Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove leading zero from d3.js timeFormat

I'm working with d3.js and I'm using this documentation.

I use this to show the hour: %I:%M which shows the hour like 02:34.

Is there a way to remove the leading zero, in this case showing the data as 2:34 ?

like image 903
Samurai Jack Avatar asked Dec 11 '22 09:12

Samurai Jack


1 Answers

As outlined in the documentation, the default padding is zero-padding for all directives except %e (for which it is space-padding).
To change the padding type, you can append a modifier to %:

  • 0 - zero-padding
  • _ - space-padding
  • - - disable padding

So, given your example: %-I:%M.

like image 160
Etheryte Avatar answered Dec 25 '22 22:12

Etheryte