a1jit Posted September 25, 2005 Posted September 25, 2005 Hi Guys, Im not sure why i cant get this done, Ijust want to retrieve two data 1) date (dd/mm/yyyy) 2) time (hh:mm:ss) Im doing this two statements but its not only giving me the date..I dont know why i cant get it formatted..Any help will be really appreciated System.DateTime.Now.ToShortDateString(),"dd/MM/yy" Time is working as i want but not date System.DateTime.Now.ToShortTimeString() Thank You Quote
*Experts* Nerseus Posted September 25, 2005 *Experts* Posted September 25, 2005 If you want a guaranteed date format, you have to provide the string. For example: date.ToString("dd/MM/yyyy hh:mm:ss") If you want am/pm at the end, try: date.ToString("dd/MM/yyyy hh:mm:ss tt") There are other format strings available - check the MSDN documentation for Custom DateTime Format Strings. Using ToShortDateString will get you a date formatted according to the OS's rules. You may abe able to override that with a custom DateTimeFormatInfo object, but I tend to prefer the custom string. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
a1jit Posted September 26, 2005 Author Posted September 26, 2005 thank you very much..the link was very useful Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.