by Rachael Arnold

http://www.rachaelarnold.com/dev/archive/why-is-date-returning-wrong

Demystifying 12/31/1969 (or 1/1/1970 for Eastern Hemisphere folk)

Since the Unix timestamp is based off the Unix Epoch, an invalid timestamp defaults to to the Epoch (Thu, 01 Jan 1970 00:00:00 +0000).

But, date() displays the formatted time taking into account the timezone of the server or a timezone set with date_default_timezone_set(), so if your timezone is set to something like America/New_York (-0500), the date will be adjusted, resulting in a time that falls during 31 Dec 1969.

So if your server or script timezone is set to a timezone in the Western Hemisphere, any invalid timestamps will end up displayed as some incarnation of 31 Dec 1969. Likewise, in the Eastern Hemisphere, the date falls on or after the Epoch, resulting in a returned value of 1 Jan 1970.

为何 UNIX 时间 0, 有时显示是1970年1月1日,有时显示是1969年12月31日的更多相关文章

  1. 生成二维码 加密解密类 TABLE转换成实体、TABLE转换成实体集合(可转换成对象和值类型) COOKIE帮助类 数据类型转换 截取字符串 根据IP获取地点 生成随机字符 UNIX时间转换为DATETIME\DATETIME转换为UNIXTIME 是否包含中文 生成秘钥方式之一 计算某一年 某一周 的起始时间和结束时间

    生成二维码 /// <summary>/// 生成二维码/// </summary>public static class QRcodeUtils{private static ...

  2. UNIX时间与本地时间的转换

    所谓UNIX时间,维基百科的解释:UNIX时间,或称POSIX时间是UNIX或类UNIX系统使用的时间表示方式:从协调世界时1970年1月1日0时0分0秒起至现在的总秒数,不包括闰秒 知道了是什么,就 ...

  3. 【測试工具】一个将Unix时间转换为通用时间的工具

    一个将Unix时间转换为通用时间的工具 演示效果: 点击转换之后变为: 源码: function calctime2(){ var time = window.document.getElementB ...

  4. Windows FILETIME 与UNIX时间的转换

    windows FILETIME时间从1601/01/01 零时零分零秒开始计时,windows每个时钟滴答将计数加一,每个时钟滴答的间隔是100 nanoseconds(纳秒,1秒=10的九次方纳秒 ...

  5. Unix时间戳 POSIX时间 Unix时间

    Unix时间戳(Unix timestamp),或称Unix时间(Unix time).POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00 ...

  6. unix时间转换为datetime\datetime转换为unixtime

    /// <summary> /// unix时间转换为datetime /// </summary> /// <param name="timeStamp&qu ...

  7. 如何将北京时间批量转为Unix时间?用Excel!

    前面我们说过Unix时间戳转换怎样在Excel批量修改,有些人就想如果有特殊需求,那能不能批量将北京时间批量转成unix时间呢?能!用Excel就可以实现!跟ytkah一起试试吧. 将unix时间戳转 ...

  8. unix 时间

    from_unixtime()是MySQL里的时间函数 mysql>SELECT FROM_UNIXTIME( 1249488000, '%Y%m%d' ) ->20071120 mysq ...

  9. MySQL与unix时间问题

    1.select unix_timestamp() -->可以返回以秒记的unix时间. 2.select from_unixtime('1455804595','%Y年%m月%d号'); -- ...

随机推荐

  1. python fabric 练习记录

    https://blog.csdn.net/freeking101/article/details/81103945   fabric 域名

  2. 1127: 【入门】A类多?B类多?

    1127: [入门]A类多?B类多? 时间限制: 1 Sec 内存限制: 16 MB 提交: 3537 解决: 2406 [提交] [状态] [讨论版] [命题人:外部导入] 题目描述 一个自然数转换 ...

  3. C、Guard the empire(贪心)

    链接:https://ac.nowcoder.com/acm/contest/3570/C 来源:牛客网 题目描述 Hbb is a general and respected by the enti ...

  4. RedHat 6.7 下安装 Cadence IC617

    操作系统:RedHat 6.7 搭建一个RedHat的本地源[1]: # mount -o /dev/cdrom1 /mnt # mkdir -p /opt/redhat/6.7 # cp -rv / ...

  5. Appium:We shut down because no new commands came in

    在使用Appium自带的Inspector来查找元素定位时,一段时间(60s)不对其进行任何操作appium就会关闭Android应用,并打印出 info: [debug] We shut down ...

  6. 1016 Phone Bills (25 分)

    A long-distance telephone company charges its customers by the following rules: Making a long-distan ...

  7. 关于$f(x)=\int_0^x\left|\sin\frac1t\right|\text dt$求导的问题

    首先,我们考虑\(f(x)\)在\(\mathbb R\)上都是定义的.根据定义,显然有\(f(0)=0\):其次,对于\(x\neq0\),不妨先设\(x\gt0\),则有在\(t\rightarr ...

  8. 怎么用scratch做大鱼吃小鱼

    行走代码不说了.出鱼代码大概就是 棋子被点击时 重复执行 移到x:从()到()任意选一个数,y一样 克隆自己 等待你想要的秒数.吃鱼代码就是 当作为克隆体启动是 重复执行 如果碰到()那么 删除克隆体 ...

  9. escape和unescape知识点

    decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码. encodeURI() 函数可把字符串作为 URI 进行编码 <script> var uri= ...

  10. linux系统管理,查看系统资源

    free 查看内存使用情况 -b  ===>  以byte为单位 -k  ===>  以Kb为单位 -m  ===>  以Mb为单位 -g  ===>  以Gb为单位 -t  ...