Q:

Ruby date format difference between %-d vs %e or "no-padded" vs "blank-padded"

In Ruby documentation, there are two very similar values for formatting a date(time) string

%-d described as no-padded (1..31)
%e described as blank-padded ( 1..31)

What's the difference between these two?

A:

The difference between these two is the following:
%-d will print out the number without leading zero nor space ex:
DateTime.new(2016, 02, 01, 16, 00).strftime('%m/%-d/%Y')
> "02/1/2016"

%e will print out a leading space but not a leading zero
DateTime.new(2016, 02, 01, 16, 00).strftime('%m/%e/%Y')
> "02/ 1/2016"

