LoginSignup
1
0

Ruby2.1技術者認定試験 Silver time.now.to_i問題解説

Posted at
Time.now.to_i

Q上のコードの実行結果は?

・解説

  • Time.now.to_i はRubyにおいて、現在のタイムスタンプを取得するためのコード。

    これを実行すると、Unixエポック(1970年1月1日)からの経過秒数が整数として返される。

  • Time.now は現在の時刻を表す Time オブジェクトを生成する。

  • to_i メソッドは、Time オブジェクトを整数として表すためのメソッド。具体的には、Unixエポックからの経過秒数(整数)を返す

A.起算時(1970年1月1日午前0時)からの経過秒数を整数で返す。

1685333172

読んでくださり、ありがとうございます!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0