Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Convert DateTime Now To second

Tags:

c#

datetime

I have the input 15:20:30

I want to convert to seconds.

like image 607
monkey_boys Avatar asked Nov 27 '22 00:11

monkey_boys


1 Answers

Seeing as though you haven't specified the question properly I have interpreted it to represent 15 hours 20 minutes and 30 seconds, as opposed to DateTime.Now. (Obviously this is the same as "How many seconds since midnight")

  TimeSpan MySpan = new TimeSpan(15, 20, 30);
  MySpan.TotalSeconds;

Although if you're only wanting the Seconds from the current DateTime.Now (this is not the TotalSeconds, just the current minutes seconds), just use:

  DateTime.Now.Second
like image 87
Lloyd Powell Avatar answered Dec 21 '22 03:12

Lloyd Powell