如何将刻度转换为日期格式? [英] How can I convert ticks to a date format?

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

问题描述

我正在将刻度值转换为这样的日期:

I am converting a ticks value to a date like this:

Convert(datetime, (MachineGroups.TimeAdded - 599266080000000000)/864000000000);

使用这个我得到:

9/27/2009 10:50:27 PM

但我只想要这种格式的日期:

But I want just the date in this format:

October 1, 2009

我的样本刻度值是

633896886277130000

最好的方法是什么?

推荐答案

可以使用特定的刻度值构造 DateTime 对象.确定刻度值后,您可以执行以下操作:

A DateTime object can be constructed with a specific value of ticks. Once you have determined the ticks value, you can do the following:

DateTime myDate = new DateTime(numberOfTicks);
String test = myDate.ToString("MMMM dd, yyyy");

这篇关于如何将刻度转换为日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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