1.今天在做一个webservice的接口的时候,被要求传一个时间戳过去,然后就是开始在Google上找

2.遇到两个问题,一,当前时间转化为时间戳,二,获取的当前时间和系统的时间相差8个小时
一,转化的方法为
    NSString *timeSp = [NSString stringWithFormat:@"%d", (long)[localeDate timeIntervalSince1970]];
    NSLog(@"timeSp:%@",timeSp); //时间戳的值
 
二,把获取的时间转化为当前时间
 NSDate *datenow = [NSDate date];//现在时间,你可以输出来看下是什么格式
    NSTimeZone *zone = [NSTimeZone systemTimeZone];
    NSInteger interval = [zone secondsFromGMTForDate:datenow];
    NSDate *localeDate = [datenow  dateByAddingTimeInterval: interval];
    NSLog(@"%@", localeDate);
 
3.把时间戳转化为时间的方法
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:1363948516];
    NSLog(@"1363948516  = %@",confromTimesp);
 
4.完成

ios 时间戳 当前时间 相互转化的更多相关文章

  1. iOS 时间戳和时间互换,计算两日期相隔天数

    /*  *获取当前系统时间的时间戳  */ +(NSInteger)getNowTimestamp;   /**  * 获取当前时间  */ + (NSString *)getNowTimeTampF ...

  2. iOS 时间戳转换为时间

    NSString *str=";//时间戳 NSTimeInterval time=[str doubleValue]+;//因为时差问题要加8小时 == 28800 sec NSDate ...

  3. C# 时间戳与时间相互转化

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 时间戳d ...

  4. iOS开发时间戳与时间NSDate,时区的转换,汉字与UTF8,16进制的转换

    http://blog.sina.com.cn/s/blog_68661bd80101njdo.html 标签: ios时间戳 ios开发时间戳 ios16进制转中文 ios开发utf8转中文 ios ...

  5. PHP 时间戳 转时间 for ios 8*3600

    // 时间戳 转时间 int intTimeString = [_model.date intValue]; NSDate *confromTimesp = [NSDate dateWithTimeI ...

  6. (转)golang获取当前时间、时间戳和时间字符串及它们之间的相互转换

    原文连接: https://blog.csdn.net/skh2015java/article/details/70051512 1.获取当前时间 currentTime:=time.Now() // ...

  7. Swift3.0 iOS获取当前时间 - 年月日时分秒星期

    Swift3.0 iOS获取当前时间 - 年月日时分秒星期func getTimes() -> [Int] { var timers: [Int] = [] // 返回的数组 let calen ...

  8. mysql取出现在的时间戳和时间时间戳转成人类看得懂的时间

    mysql取出现在的时间戳和时间时间戳转成人类看得懂的时间,我们在mysql里面他封装了一个内置的时间戳转化的函数,比如我们现在的时间戳是:1458536709 ,"%Y-%m-%d&quo ...

  9. IOS时间戳

    什么是时间戳? 时间戳(timestamp),通常是一个字符序列,唯一地标识某一刻的时间.数字时间戳技术是数字签名技术一种变种的应用. 思考:简单来讲就是根据文件hash加密后生成的摘要和时间生成的时 ...

随机推荐

  1. TrustedBSD Mandatory Access Control Framework分析

    本文为CoryXie原创译文,转载及有任何问题请联系cory.xie#gmail.com. 本文分析FreeBSD 10.0[ http://xrefs.info/freebsd-10.0/ ]的MA ...

  2. 无线物联网中CoAP协议的研究与实现【转】

    无线物联网中CoAP协议的研究与实现 时间:2013-04-09 来源:电子科技 作者:汤春明,张 荧,吴宇平 关键字:CoAP   无线   物联网   协议 摘要:由于物联网中的很多设备都是资源受 ...

  3. 【19.46%】【codeforces 551B】ZgukistringZ

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. [NPM] Run npm scripts when files change with onchange

    In this lesson we will look at how we can setup our npm scripts to execute when the file system has ...

  5. 微信公众号开发之怎样将本机IP映射成外网域名

    近期一个项目须要用到微信公众号的网页授权登录,在研究这个公众号的时候遇到各种困难,现将自己的一些心得总结一下. 我想进行微信公众号开发遇到的第一个困难就是微信公众号必须输入一个外网能够訪问的域名,在网 ...

  6. 【codeforces 791A】Bear and Big Brother

    [题目链接]:http://codeforces.com/contest/791/problem/A [题意] 给你两个数字a和b; a每次乘3,b每次乘2 问你什么时候a第一次大于b [题解] 傻逼 ...

  7. TensorFlow: couldn’t open CUDA library cupti64_80.dll、InternalError: Blas SGEMM launch failed

    1. couldn't open CUDA library cupti64_80.dll Win10 TensorFlow(gpu)安装详解 在资源管理器中查询 cupti64_80.dll 的位置. ...

  8. 一个简易版的Function.prototype.bind实现

    重新看<JavaScript设计模式与开发实践>一书,第32页发现个简易版的Function.prototype.bind实现,非常容易理解,记录在这了. Function.prototy ...

  9. IP packet transmission using vehicular transport

    In one embodiment, a first stationary router may detect a disconnected backhaul link to a destinatio ...

  10. Solid-state storage management

    Solid-state storage management for a system, the management including establishing, externally to a ...