Get current date in milliseconds

前端 未结 12 794
别跟我提以往
别跟我提以往 2020-12-04 10:23

Can any one give me an idea how to get the current date in milliseconds?

12条回答
  •  广开言路
    2020-12-04 11:01

    Casting the NSTimeInterval directly to a long overflowed for me, so instead I had to cast to a long long.

    long long milliseconds = (long long)([[NSDate date] timeIntervalSince1970] * 1000.0);
    

    The result is a 13 digit timestamp as in Unix.

提交回复
热议问题