By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

How to convert string into time format in asp.net

P: 1
I have 00:01:00 in a string.
I want to convert it into time format.
How can i do this?
Aug 24 '07 #1
Share this Question
Share on Google+
4 Replies


kenobewan
Expert 2.5K+
P: 4,871
I assume that this represents 1 min. Either way split the string and convert to time. HTH.
Aug 24 '07 #2

chazcross
P: 31
im not sure if this is what you want

Expand|Select|Wrap|Line Numbers
  1. string s = "00:01:00";
  2. DateTime d = DateTime.Parse(s);
  3. Response.Write(d.ToShortTimeString());
this will return 12:01 AM
Aug 29 '07 #3

P: 8
hmm...

I have something similar to this but in my case this will not work. I have a text field storing the value in mins in this format 000100 representing 1 min.

I need to break this into a time reference 00:01:00 so that I can use it to calculate total time spent.

I have tried several different date/time functions but they all add the date, which I do not need.

question is: is there a way to convert this text into a time only field ?

i.e. Duration time/duration
005005 ... 00:50:05
000905 ... 00:09:05
001500 ... 00:15:00

total 01:14:10

thanks for you help!
Aug 30 '07 #4

Plater
Expert 5K+
P: 7,872
TimeSpan object.
(Note: They inter-twine very well with the DateTime object)
But you should be able to create a timespan object from a number of secods or minutes, or whatever
Aug 30 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.