DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Date Time Format In RUBY

07.07.2006
| 388883 views |
  • submit to reddit
        ------------------------------------------------------------------- Time#strftime
time.strftime( string ) => string
---------------------------------------------------------------------------------
Formats time according to the directives in the given format string. Any text not listed as a directive will be passed through to the output string.

"
Format meaning:

  %a - The abbreviated weekday name (``Sun'')
  %A - The  full  weekday  name (``Sunday'')
  %b - The abbreviated month name (``Jan'')
  %B - The  full  month  name (``January'')
  %c - The preferred local date and time representation
  %d - Day of the month (01..31)
  %H - Hour of the day, 24-hour clock (00..23)
  %I - Hour of the day, 12-hour clock (01..12)
  %j - Day of the year (001..366)
  %m - Month of the year (01..12)
  %M - Minute of the hour (00..59)
  %p - Meridian indicator (``AM''  or  ``PM'')
  %S - Second of the minute (00..60)
  %U - Week  number  of the current year,
          starting with the first Sunday as the first
          day of the first week (00..53)
  %W - Week  number  of the current year,
          starting with the first Monday as the first
          day of the first week (00..53)
  %w - Day of the week (Sunday is 0, 0..6)
  %x - Preferred representation for the date alone, no time
  %X - Preferred representation for the time alone, no date
  %y - Year without a century (00..99)
  %Y - Year with century
  %Z - Time zone name
  %% - Literal ``%'' character

   t = Time.now
   t.strftime("Printed on %m/%d/%Y")   #=> "Printed on 04/09/2003"
   t.strftime("at %I:%M%p")            #=> "at 08:56AM"
"
    

Comments

Zoltan Zarka replied on Wed, 2014/10/29 - 4:46pm

Email marketing has proved to be one of the most effective digital promotion techniques, with its capacity to reach a vast audience very quickly and at the lowest cost. That is why it's important not to underestimate the technical aspects of email delivery.  Now common email providers like Yahoo! Mail or Gmail do not allow you to send unlimited emails at once: they  have some strict limitations both for the number of messages and the number recipients you can handle per day.www.unlimitedsmtp.biz 

Zoltan Zarka replied on Wed, 2014/10/29 - 4:45pm

Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.www.cheapsmtp.info 

Jak Down replied on Wed, 2014/10/29 - 1:16pm

 Hello! I just wish to give an enormous thumbs up for the nice info you've got right here on this post. I will probably be coming back to your weblog for more soon foods to conceive a baby boy naturally

Jak Down replied on Wed, 2014/10/29 - 11:02am

 There are many people who desire to build muscles on their bodies. You might be one of them and you are probably wondering why your daily workout is not effective. hyppagu insurance

Jak Down replied on Wed, 2014/10/29 - 9:25am

 This is exactly what I was looking for. Thanks for sharing this great article! That is very interesting Smile I love reading and I am always searching for informative information like this! being with a guy who won't commit

Jak Down replied on Wed, 2014/10/29 - 5:44am

 I ‘d mention that most of us visitors are really endowed to exist in a fabulous place with very many wonderful individuals with very helpful things. f4x book

Jak Down replied on Tue, 2014/10/28 - 6:44am

 There are many people who desire to build muscles on their bodies. You might be one of them and you are probably wondering why your daily workout is not effective. Attorneys In Columbus Georgia

Jak Down replied on Tue, 2014/10/28 - 3:24am

 
There are many people who desire to build muscles on their bodies. You might be one of them and you are probably wondering why your daily workout is not effective. ets 2 mods

Jak Down replied on Tue, 2014/10/28 - 2:31am

 
This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck. kyle leon's adonis golden ratio reviews

Jak Down replied on Sun, 2014/10/26 - 2:56am

 Your good knowledge and kindness in playing with all the pieces was very useful. I don’t know what I would have done if I had not encountered such a step like this immigration laws

Jak Down replied on Sat, 2014/10/25 - 9:48am

 I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the excellent work. bakterien

Jak Down replied on Sat, 2014/10/25 - 6:21am

 All the contents you mentioned in is too good and can be very useful. I will keep it in mind, thanks for sharing the information keep updating, looking forward for more posts.Thanks sieb

Jak Down replied on Fri, 2014/10/24 - 5:04am

 There are many people who desire to build muscles on their bodies. You might be one of them and you are probably wondering why your daily workout is not effective rebelmouse.com

Jak Down replied on Thu, 2014/10/23 - 5:16am

 I have browsed most of your posts. This post is probably where I got the most useful information for my research loyal 9 marketing scam

Jak Down replied on Thu, 2014/10/23 - 3:43am

 Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. loyal 9 marketing reviews

Jak Down replied on Thu, 2014/10/23 - 2:28am

 We are an Internet Marketing and Management company Specializing in Search Engine Optimization, Website Design and Social Media Campaign Development. loyal 9 reviews

Abdel Zoo replied on Wed, 2014/10/22 - 7:04pm

  Thanks for your efforts  g9g 2014 games

Jak Down replied on Tue, 2014/10/21 - 6:46am

 
There are many people who desire to build muscles on their bodies. You might be one of them and you are probably wondering why your daily workout is not effective click

cris ma replied on Tue, 2014/06/10 - 1:01pm

 LED lights nowadays are a matter of great deal of thought for practicality reason. Electric companies are charging more and one thing is sure, they will continue to raise the rate.

LED Lights For Home

Alex Jee replied on Tue, 2014/05/13 - 10:55am in response to: Ahsan Gill

A great website accompanying fascinating also lone stuff what more would you demand.http://www.wmaker.net/regarder-film/ 

Alex Jee replied on Mon, 2014/02/24 - 12:06pm in response to: Ahsan Gill

I visualize the greatest texts on your blog further I certainly affection lesson them.
Transporting a horse 

Ahsan Gill replied on Tue, 2014/02/04 - 2:02pm

Wow! I really appreciate the thought that you put into this article. This topic has been something I have been looking into for a few hours and your post is one of the best I have read. bodyguar services in rio de jeneiro bodyguard services in sao paulo bodyguard services in sochi bodyguard services in russia

Engr Ubaid Masood replied on Mon, 2014/02/03 - 1:21am

Hi,

This is great informative and helpful blog , thanks for sharing

Regards,

 

Construction Site in London 

hire domestic workers in london 

Hire security in london 

www.ibodyguardlondon.com

Alex Jee replied on Sat, 2014/03/01 - 1:05pm in response to: Ahsan Gill

Your blogs furthermore entire split matter are so interesting besides moneymaking it prepares me happen retreat most afresh.
solda mig usada 

Ankur Sharma replied on Wed, 2013/11/20 - 1:58am

LED Bulbs
The energy efficient nature of LEDs allows them to produce brighter light than other types of www.myledlight.co.uk bulbs while using less energy.

Ankur Sharma replied on Wed, 2013/11/13 - 5:16am

 Design is the fundamental soul of a man-made creation that ends up expressing itself in successive outer layers of the product or service. The iMac is not just the color or translucence or the shape of the shell. Energy

Ankur Sharma replied on Fri, 2013/10/18 - 4:49am

 seo group of jhansi, social media optimization, link building,social bookmarking,article submission services,<a href="http://onlineseojhansi.blogspot.in/">best services in jhansi</a>online seo in jhansi,link building services,best services in jhansi
<a href="http://seogroupofjhansi.blogspot.in/">Link building</a>

Ankur Sharma replied on Thu, 2013/10/17 - 2:29am

 auto body paint NY, clearcoat, clearcoat NY, Car Paint, Auto body Paint, Toners from Silver Sails Paints at AutoBodyPaintStore.com Auto Body Paint

Ankur Sharma replied on Thu, 2013/10/17 - 1:20am

 Die größten Katalog von Objekten mit direkten Kontakten zu Eigentümern und sicherlich billigsten Unterkünfte rund um die Küste von Kroatien Ferienhaus Kroatien

Andreea Socolov replied on Sun, 2013/10/13 - 8:18am

How about the employee time clocks at TimeClockeShop.com? Aren't these a good choice as well? There's too much technology..

Ankur Sharma replied on Thu, 2013/10/10 - 6:58am

  Thanks for taking the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you gain knowledge, would you mind updating your blog with more information? It is top female combat boots on the market 

Ankur Sharma replied on Mon, 2013/10/07 - 12:26am

 

It is our good luck that I found this meaning ful article to study because there is a lots of topics to study what can increase our social sites knowledge blinds bolton

Ankur Sharma replied on Sun, 2013/10/06 - 1:34am

 

Your post is very exciting and informative. I am planning to decide on a career move and this has helped me with one aspect. Thanks man!
hindi shayari

Ankur Sharma replied on Fri, 2013/10/04 - 1:45am

 

This web page may be a walk-through like the knowledge you wished about it and didn’t know who to ask. Glimpse here, and you’ll definitely discover it. short term loans

Ankur Sharma replied on Tue, 2013/10/01 - 11:50am

 Oh where am I gonna find a free feeling
Oh the one I've always wanted to know
Where I am not afraid of revealing, oh no
I'll show whatever I want whenever I want
Well I've done an awful lot of concealing

matta

Ankur Sharma replied on Tue, 2013/10/01 - 5:31am

Ferienhaus Kroatien
Die größten Katalog von Objekten mit direkten Kontakten zu Eigentümern und sicherlich billigsten Unterkünfte rund um die Küste von Kroatien

Ankur Sharma replied on Mon, 2013/09/30 - 3:44am

 kanhagranites is a granite exporters in india , professional company involved in the processing, granite slabs wholesale and retailing of Indian Granite.granite slabs

Sadia Sulaman replied on Tue, 2014/07/01 - 1:32am in response to: Ankur Sharma

 Your blog has some of the most fascinating information! I've read several pages here and I just had to comment and let you know that I thought you've been doing a great job here.

BlogHuts

Ankur Sharma replied on Thu, 2013/09/26 - 4:30am

 Really nice designer platform, in my opinion, definitely something of interest to me. Best Backlinks Provider

Ankur Sharma replied on Mon, 2013/09/09 - 11:37pm

 Daily Audio Bible - listen online, on demand topics and episodes, location, contact, schedule and broadcast information.audio bible

Ankur Sharma replied on Mon, 2013/09/09 - 1:10am

auto body paint ny and Auto Paint, Toners from Silver Sails Paints in business profiles,
contact information, services and more.auto body paint ny

Ankur Sharma replied on Sun, 2013/09/08 - 2:43am

 kanhagranites is a wholesale and retailing in india.granite slabs

Ankur Sharma replied on Fri, 2013/08/30 - 10:13am

 Thank you for taking the time to publish this information very helpful!I've been looking for books of this nature for a way too long. I'm just glad that I found yours. Looking forward for your next post.

hackett shop

Ankur Sharma replied on Fri, 2013/08/23 - 2:48am

 I appreciate the work of all people who share information with others. Great Blog! kamagra

Ankur Sharma replied on Thu, 2013/08/22 - 6:19am

 Your Land Rover Range Rover is a tough vehicle but when it comes time to buy parts, you’ll always want to consider buying genuine Land parts We have Pioneered many Land Rover Parts to make life better for the Land Rover ecift 

Ankur Sharma replied on Mon, 2013/08/19 - 4:35am

 System that can help got a superb blogging site   .I shall be excited about more related matters. i see you bought honestly extremely helpful themes , i'll be always taking a look at your web page thank you. karmaloop rep code

Ankur Sharma replied on Sat, 2013/08/17 - 11:45pm

 You may write about the offers on the blog. You could broadcast it’s super. Your blog assessment should escalate your opt-ins. karmaloop rep code  

Ankur Sharma replied on Sat, 2013/08/17 - 3:38am

 

I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. karmaloop promo code