Formatting Now

  • Thread starter Thread starter reidarT
  • Start date Start date
R

reidarT

I use this in a label
DateTime d1 = DateTime.Now;

this.lblTime.Text = d1.ToString();

but I get the date and time in this format 21.02.2002 23:45:00

I only want 23:45

regards

reidarT
 
I use this in a label
DateTime d1 = DateTime.Now;

this.lblTime.Text = d1.ToString();

but I get the date and time in this format 21.02.2002 23:45:00

I only want 23:45

Look at the help for DateTime.ToString()

this.lblTime.Text = d1.ToString("t");

Joanna
 

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