How to generate timestamp unix epoch format nodejs?

后端 未结 7 1694
感动是毒
感动是毒 2021-01-31 06:54

I am trying to send data to graphite carbon-cache process on port 2003 using

Ubuntu terminal:

echo "test.average 4 `date +%s`" | nc -q0 127.0.0.1         


        
7条回答
  •  鱼传尺愫
    2021-01-31 07:34

    Using momentjs:

    The following two variables have the same value:-

    console.log(moment().format('X'))
    console.log(moment.utc().format('X'))
    

    Using Date() built-in:

    console.log(new Date().getTime())   // including fractional seconds
    console.log(Math.floor(new Date().getTime()/1000))    // up to seconds
    

提交回复
热议问题