转换日期时间长,也是其他方式 [英] Convert DateTime to long and also the other way around

查看:136
本文介绍了转换日期时间长,也是其他方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欲存储日期作为表号码。我知道该怎么做,但我不知道怎么回去。我怎样才能投下了长长的变量ToDateTime。

I want to store dates as numbers in a table. I know how to do that but I don't know how to go back. How can I cast a long variable to ToDateTime.

DateTime now = DateTime.Now;
long t = now.ToFileTime();
DateTime today = t.ToDateTime;  // I am looking for something like this line. This Method does not exist

我知道有转换日期时间长了很多方法。我不介意使用哪种技术。我只是希望能有一种方法,我可以来回转换。

I know there are many ways of converting DateTime to long. I don't mind which technique to use. I just want to have a way where I can convert back and forth.

推荐答案

要长从日期时间:

长DateTime.Ticks

要日期时间从长:

新的日期时间(长)

这篇关于转换日期时间长,也是其他方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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