Leading Zero for time



Lesson: Extend your Knowledge: Time, Here and Now

My question is about time, after the code below. But follow to see why I ask the question.

I happened to have coded this at 9:05 and noticed that it returned

=> It's 9:5 AM

Thankfully I was coding not 5 minutes sooner or later, I would have thought I understood time.

After a lot of searching, I found a few things I didn't understand how to implement. Eventually I found strftime and began to understand it. Hopefully codecademy will explain this further, but I decided to post this lest someone else go down the rabbit hole.
Info about strftime : http://ruby-doc.org/core-2.1.0/Time.html#method-i-strftime

module ThePresent
  def now
#      t=Time.new(2017,2,23,9,5,3,"-07:00")
puts t.zone
puts l.zone
      puts l.strftime("Localtime is %A the %e %I:%M%p %Z")
    puts t.strftime("Zulu time is %A the %e %I:%M%p %Z")
 #   puts "It's #{t.hour > 12 ? t.hour - 12 : t.hour}:#{t.min} #{t.hour > 12 ? 'PM' : 'AM'} (GMT)."

class TheHereAnd
  extend ThePresent


My question: Why does local time equate to the same as UTC? Not PST
How/Can Ruby obtain the user's local time?



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.