Link to home
Start Free TrialLog in
Avatar of austinpeck
austinpeck

asked on

Format Time

Hi,  I had some problem formating the date in ASP.NET. Here is my code:
     
Dim mydate As DateTime = CDate(kivdate.Text)
Dim test As String = Format(mydate, "dd/MMM/yyyy")

When I input data such as "10/01/03" in the kivdate textbox i would like it to display it as
10-Jan-03 but then i appear as 01-Oct-03. I had already specify the format of the date to dd/mmm/yyy but it is that the data does not format into the type i want.


Avatar of iboutchkine
iboutchkine

Check your Regional Setting in CVontrol panel
The format of the date you are getting, has nothing to do with any setting in ControlPanel. The format of date is dependent on the culture info of current executing thread. Bydefault most browsers have US as the first language and in web.config the default language is en-us. This results in the type of date format you are getting.
You will have to suply a FormatProvider object when you convert the string to DateTime object.
ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of austinpeck

ASKER

Well your codes seems like Java to me. The languge I am using is ASP.NET VB. Anyway thanks for the solution but i still can't slove this problem
The sample code is C#, not java.
What is the error that you are still getting? Have you tried using similar code in VB.Net
Sorry my progamming languge is not that good. What i did is that i copy the whole chuck of code you provide into my code.
This are the following errors.
1. Name 'DateTimeFormatInfo' is not declared.
2. Name 'Dtfmt' is not declared
3. Name 'dt' is not declared

Since your code is in C# is there anyway that you can help me convert to VB.net?
thanks you.
For formating info you will need to import System.Globalization namespace in your code. And you will need to remove the Console.WriteLine statements becasue they were for Console app and not for ASP.Net app.