将Unix时间戳秒转换为毫秒

时间:2013-12-20 10:28:02

标签: objective-c time unix-timestamp

我知道这个问题已经多次被回答过:

  1. here
  2. here
  3. here
  4. 以及其他
  5. 但这个狗屎不起作用,我不明白为什么。这就是我已经做过的事情:

    //First try
    int currentTime  = [[NSDate date] timeIntervalSince1970] *-1000;
    //Second try
    int currentTime  = [[NSDate date] timeIntervalSince1970];
    NSInteger milliseconds      = currentTime*1000;
    //Third try
    float currentTime  = [[NSDate date] timeIntervalSince1970];
    currentTime  = currentTime * 1000;
    //Fourth try
    long currentTime  = [[NSDate date] timeIntervalSince1970];
    currentTime  = currentTime * 1000;
    

    但这总是打印出与260694392完全不同的东西。当我做的时候

    float currentTime  = [[NSDate date] timeIntervalSince1970];
    

    它以秒为单位给出了正确的时间,但是现在我还要将它乘以1000以得到毫秒数

0 个答案:

没有答案
相关问题