[[Ruby]]

*内容 [#ved13244]
Rubyで日付を取得するにはdateライブラリを読み込んだ上でDateクラスのオブジェクトを作成したうえでstftimeメソッドで必要なフォーマットに変換できます。

*記述 [#n6910903]
 require 'date'
 
 thisyear = Date.today
 thismonth = Date.today
 thisdate = Date.today                                                                                                                                                        
 sd1 = thisyear.strftime("%Y")
 sd2 = thismonth.strftime("%m")  
 sd3 = thisdate.strftime("%d")
 
 print #{sd1}/#{sd2}/#{sd3}

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS