Created
May 22, 2015 05:42
-
-
Save darui00kara/97c884bd8fc395660c33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: utf-8 | |
| # File Name: date_time.rb | |
| # Create Day is 2015/05/22 | |
| # Last Update Day is 2015/05/22 | |
| # Require List | |
| require 'date' | |
| puts "DateTimeクラス" | |
| date_time = DateTime.now | |
| puts date_time | |
| # フォーマットを指定して出力する | |
| print "%Y年%m月%d日 = ", date_time.strftime("%Y年%m月%d日"), "\n" | |
| puts | |
| print "日付%x = ", date_time.strftime("日付%x"), "\n" | |
| puts | |
| print "%H時(=%I時)%M分%S秒 = ", date_time.strftime("%H時(=%I時)%M分%S秒"), "\n" | |
| puts | |
| print "時刻%X = ", date_time.strftime("時刻%X"), "\n" | |
| puts | |
| print "タイムゾーン = ", date_time.strftime("%Z"), "\n" | |
| puts | |
| print "日付+時刻 = ", date_time.strftime("%c"), "\n" | |
| puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment