How can I convert ticks to a date format?

前端 未结 4 512
心在旅途
心在旅途 2020-11-27 20:06

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

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

Using th

4条回答
  •  遥遥无期
    2020-11-27 20:28

    It's much simpler to do this:

    DateTime dt = new DateTime(633896886277130000);
    

    Which gives

    dt.ToString() ==> "9/27/2009 10:50:27 PM"
    

    You can format this any way you want by using dt.ToString(MyFormat). Refer to this reference for format strings. "MMMM dd, yyyy" works for what you specified in the question.

    Not sure where you get October 1.

提交回复
热议问题