this time

  • Thread starter Thread starter Snuyt
  • Start date Start date
S

Snuyt

Hallo,

How can I make a datetime object that contains the current clocktime ?

Thanks
Snuyt
 
Snuyt said:
Hallo,

How can I make a datetime object that contains the current clocktime ?

Thanks
Snuyt

Ok, never mind, I found it myself

Private CurrentTime As DateTime = DateTime.Now


Thanks anyway
Snuyt
 
Snuyt,
Do you want just the time or the current Date & Time?

As the others have pointed out you can use:

To get the current Date & Time
dim mydatetime as datetime = now
dim mydatetime as datetime = DateTime.Now


To get the current date (without a Time)
dim mydatetime as datetime = DateTime.Today


To get just the current Time (without a Date)
dim mydatetime as datetime = DateTime.Now
mydatetime = New DateTime(mydatetime.Subtract(mydatetime.Date).Ticks)

The later is available under the Microsoft.VisualBasic.DateAndTime module

Dim mydatetime = TimeOfDay

The first is useful if you have a datetime value & want just the time, the
later is useful if you want the current time.

For further details on date & time operations see:

Microsoft.VisualBasic.DateAndTime
(I don't see a nice URL to this class... You can use Object Browser in
VS.NET to see the members )

System.DateTime

http://msdn.microsoft.com/library/d.../cpref/html/frlrfSystemDateTimeClassTopic.asp

System.TimeSpan

http://msdn.microsoft.com/library/d.../cpref/html/frlrfSystemTimeSpanClassTopic.asp

Hope this helps
Jay
 
Back
Top