How to get the current time as 13-digit integer in Ruby?

后端 未结 7 444
闹比i
闹比i 2020-12-04 11:35

I have this jQuery function that returns the current time as the number of milliseconds since the epoch (Jan 1, 1970):

time = new Date().getTime         


        
相关标签:
7条回答
  • 2020-12-04 12:41
    require 'date'
    
    p DateTime.now.strftime('%s') # "1384526946" (seconds)
    p DateTime.now.strftime('%Q') # "1384526946523" (milliseconds)
    
    0 讨论(0)
提交回复
热议问题