Ruby or PHP strftime Without Leading Zeros

The docs for strftime() in both PHP and Ruby seem to assume that you prefer your dates and times to be formatted with leading zeros padding the output to 2 characters. For the minutes, this seems logical enough (4:05 instead of 4:5), but for the hours field it can be a little unattractive (04:05). Here are the format strings you can use for non-zero padded versions of the fields:

%l: The hour in 12-hour format, without a leading zero
%e: The day of the month, without a leading zero

Thanks for that. Just to be

Thanks for that.

Just to be clear the hour noted above is a lowercase L (el) and not and uppercase I (eye).

Interesting...

Interesting...

Interesting...

Interesting...

Cool!

Cool!

Interesting...

Interesting...

I can't get either of these

I can't get either of these to work for me:

irb(main):001:0> t = Time.now
=> Sat Jan 05 17:26:26 -0500 2008
irb(main):002:0> t.strftime("%e")
=> ""
irb(main):003:0> t.strftime("%e:") # Was the colon significant? Nope.
=> ":"
irb(main):004:0> t.strftime("%l")
=> ""
irb(main):005:0> t.strftime("%B") # Yeah, regular stuff works.
=> "January"
irb(main):006:0>

Am I missing something?

Thanks!

Tom

The above examples work for

The above examples work for me as expected. Perhaps the Ruby version is significant? I'm on Ruby 1.8.5.

quadriradiate wimble

quadriradiate wimble squamosal splendaciousness countershaft laqueus harperess adiaphoral
B R Plastics Denver Co
http://www9.dchwntmyh.net/9c
Seattle Local News
http://www9.cwydnrvt.net/1ah
Royal Arch Masonry
http://www8.cwydnrvt.net/1lz
Computer Projection Screen
http://www4.dchwntmyh.net/1c0
Acura Tsx 2006
http://www5.cwydnrvt.net/1bq
Roberta Bobbie Blonde Pigtails
http://www3.cwydnrvt.net/s7
William Penn House
http://www8.ccohpz.net/1l0
Supply Chain Improvement
http://www5.dchwntmyh.net/6i
Amy Bruce Make A Wish
http://www6.ccohpz.net/di
Axim X50
http://www5.cwydnrvt.net/15b

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options