Reputation: 10542
I am looking to only get the starting hour.
Example:
if its 1:26 PM i would need it to say 1:00 PM.
Likewise, if it was 1:59 PM i would need it to also say 1:00 PM.
I can not seem to find some code that does that?
What do i need to include with my code below in order to do that above?
Dim tmpTime As DateTime = Format(Now, "h:mm tt")
MsgBox(tmpTime.Subtract(Format(Now, "mm")))
Any help would be great! Thanks!
Upvotes: 0
Views: 4759
Reputation: 216243
Just create a new DateTime in this way
Dim tmpTime As DateTime = new DateTime(1,1,1,DateTime.Now.Hour, 0, 0)
Or this
Dim tmpTime = DateTime.Now.AddMinutes(-DateTime.Now.Minute)
tmpTime = tmpTime.AddSeconds(-tmpTime.Second)
now to the display the time you have just a format problem
Console.WriteLine(tmpTime.ToString("h:mm tt"))
Upvotes: 1