중고 신입이 개발해보기..

Time.zone.now 본문

Back-End /Ruby On Rails

Time.zone.now

rootkaien 2021. 8. 20. 03:41

time = Time.zone.now
=> Fri, 20 Aug 2021 03:26:04 KST +09:00

 

 time.to_date.to_formatted_s(:number)
=> "20210820"

 

 time.to_datetime.to_formatted_s(:number)
=> "20210820032604"

 

time.to_time.to_formatted_s(:number)
=> "20210820032604"

 

 Time.zone.now.strftime('%Y-%m-%d %H:%M:%S')
=> "2021-08-20 03:41:33"

 

Time.zone.now.strftime("%Y%m%d")
=> "20210820"

 

Time.zone.now.strftime("%H%M%S")
=> "034352"

 

'Back-End > Ruby On Rails' 카테고리의 다른 글

레일즈 디비 설정 변경  (0) 2022.03.17
배열 정렬  (0) 2021.09.23
Rails Migration 사용  (0) 2021.04.30
Rails + Heroku 배포하기  (0) 2021.02.05
with_indifferent_access Hash 접근시 . 심블, 스트링 다 가능하게..  (0) 2020.10.29
Comments