Y
Y
Yuri Denisov2015-05-28 21:05:00
C++ / C#
Yuri Denisov, 2015-05-28 21:05:00

How to convert date in c# without time to unixtime?

Good evening everyone!
There was a question about the date. To convert Datetime C# to UnixTime I use code like this:

var epoch = (timePicker.Value - new DateTime(1970, 1, 1)).TotalSeconds;

Everything converts well, of course, but it does it to the nearest second. And I just need to get, for example, 05/29/2015 21:00:00. Those. the date is normal and the time is always 21:00:00.
For example, a person chose DateTime 03/23/2015, I convert it to UnixTime and should get 1427144400, which will be 23 Mar 2015 21:00:00 GMT in normal time. And so on any date!
How to set up DateTime or how to convert it so that the time when translated back is 21:00:00?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question