DateTime + representing only the time

  • Thread starter Thread starter DaTurk
  • Start date Start date
D

DaTurk

Hi,

I only need to represent the time, not the day. Is there any other
structure I can use beside DateTime? Because the constructor doesn't
have the ability to take the time alone.

Thanks
 
DaTurk,

You want to use the TimeSpan structure for this.

Hope this helps.
 
I believe there is no structure just to manipulate time. I would suggest
that you can use one of the overloaded constructor of Datetime and
provide minimum date i.e 01/0/01.
Example:
DateTime dt = new DateTime (1, 1, 1, hour, minute, sec).
 
Tariq Karim said:
I believe there is no structure just to manipulate time. I would suggest
that you can use one of the overloaded constructor of Datetime and
provide minimum date i.e 01/0/01.
Example:
DateTime dt = new DateTime (1, 1, 1, hour, minute, sec).

No, Nick's right - TimeSpan is appropriate here. That's what
DateTime.TimeOfDay returns, for example.
 
Jon Skeet said:
No, Nick's right - TimeSpan is appropriate here. That's what
DateTime.TimeOfDay returns, for example.
It has a disadvantage. It doesn't support format strings similar to
DateTime.
But you still can access single values of minute and hour etc. and construct
a format.

Christof
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top