Skip to content

Instantly share code, notes, and snippets.

@darui00kara
Created May 22, 2015 05:42
Show Gist options
  • Select an option

  • Save darui00kara/97c884bd8fc395660c33 to your computer and use it in GitHub Desktop.

Select an option

Save darui00kara/97c884bd8fc395660c33 to your computer and use it in GitHub Desktop.
# 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