Date formats confusion

Posted by RohiK under C# on 3/7/2011 | Points: 10 | Views : 1559 | Status : [Member] | Replies : 3
Hi all,

I have one confusion regarding date formats..

I want to display datetime in MM/dd/yyyy.
everything I do and it works finely on my machine. but when I change my machine datetime format to dd/MM/yyyy everything works something horribly.

sometime the culterInfo en-us returns dd/mm/yyyy and sometime it returns mm/dd/yyyy
what to do?


I want to describe it more.
I am passing dates in textbox in mm/dd/yyyy format and when I have to change it again then if user don't want to change and it clicks ok. then
I convert that textbox text into date by applying en-us culterinfo at that time it will convert date (sometime) mm/dd or sometime dd/mm
I don't know what to do?

Happy Programming!!
Rohi



Responses

Posted by: Gsolvers on: 3/7/2011 [Member] Starter | Points: 25

Up
0
Down
Did you try using Date.Format function?

It will take a format expression and date and will return the output in the required format.
format(date,"mm/dd/yyyy"))

Best Regards,

VG
www.TeacherJi.com

RohiK, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RohiK on: 3/7/2011 [Member] Starter | Points: 25

Up
0
Down
Sorry not working!

I want to follow the steps -

1. get date from textbox -is in mm/dd/yyyy format
2. convert that date in MMM,dd yyyy like 7 Mar 2011

while converting 2 time gives error

Happy Programming!!
Rohi

RohiK, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsolvers on: 3/7/2011 [Member] Starter | Points: 25

Up
0
Down
date dt = format(text1.text,"mm/dd/yyyy")
dt=Format(dt,"dd MMM yyyy")

TRY THIS


Best Regards,

VG
www.TeacherJi.com

RohiK, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response