将刻度转换为Unix时间戳 [英] Convert ticks to unix timestamp

查看:96
本文介绍了将刻度转换为Unix时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获取开始时间634942626000000000和结束时间634942638000000000.如何将其转换为Unix时间戳?我想在PHP中显示格式化的日期/时间吗?

I m getting start time 634942626000000000 and end time 634942638000000000. How can I convert it to a Unix timestamp? I want to display formatted date/time in PHP?

推荐答案

C#ticks是自午夜0001-01-01 00:00:00开始的滴答数(每个滴答是1/10000000秒),而UNIX timestamp是自开始以来的秒数. UNIX时代(1970-01-01 01:00:00),因此所需的结果是$seconds = 634942626000000000/10000000 - $number_of_seconds,其中$number_of_seconds0001-00-01 00:00:001970-01-01 01:00:00之间的秒数.因此,您现在所要做的就是确定$number_of_seconds等于什么.

C# ticks is a number of ticks since midnight 0001-01-01 00:00:00 (every tick is 1/10000000 of second) and UNIX timestamp is number of seconds since beginning of the UNIX epoch (1970-01-01 01:00:00), so desired result is $seconds = 634942626000000000/10000000 - $number_of_seconds, where $number_of_seconds is seconds between 0001-00-01 00:00:00 and 1970-01-01 01:00:00. So, all you need now is to determine what $number_of_seconds is equals.

更新:这是在C#中的操作方法:

Update: this is how to do it in C# : How to convert a Unix timestamp to DateTime and vice versa?

更新2 使用此简单脚本 http://hastebin.com/lefiyiheju. mel 确定$number_of_seconds是62136892800,但我不知道它是否准确

Update 2 Using this simple script http://hastebin.com/lefiyiheju.mel determined that $number_of_seconds is 62136892800, but I don't know if it is much accurate

这篇关于将刻度转换为Unix时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆