I have this code in VB . NET
dim date_e As DateTime
date_e = New DateTime(CLng(Convert.ToDouble("635434240520170000")))
The result is:
12.08.2014 07:07:32
Now my question is how i can reverse that encoding to obtain the number from a specific date and time witch i input myself: Lets' say.
22.09.2014 07:07:32
Thank you!
The DateTime
constructor that takes a Long
are the ticks since January 1, 0001 at 00:00:00.000 in the Gregorian calendar.
You just need to parse the string to Date
first, then you can use it's Ticks
property:
Dim dt = Date.Parse("22.09.2014 07:07:32") ' presumes that this is the correct format
Dim ticks As Long = dt.Ticks
If the input date-string is in a different format than your current culture you can use Date.Parse
with the correct culture:
dt = Date.Parse("22.09.2014 07:07:32", New CultureInfo("de-DE"))
or - if you don't know the culture but only the format - Date.ParseExact
:
dt = Date.ParseExact("22.09.2014 07:07:32", "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With