bungpeng Posted February 19, 2004 Posted February 19, 2004 I want to get today date in dd/MM/yyyy format, but no matter what method I use, I still can't get the format I want. txtDate.Text = Format(Now, "dd/MM/yyyy") txtDate.Text = Now.ToString("dd/MM/yyyy") txtDate.Text = Format(Today.Date, "dd/MM/yyyy") I still get date in dd-MM-yyyy, example: 19-02-2004 If I move this application to other PC, it work fine. I just want to know which Windows setting affect the result? Quote
*Experts* Nerseus Posted February 19, 2004 *Experts* Posted February 19, 2004 If you use Now.ToString("dd/MM/yyyy") it should override any built in windows settings. I thought the Windows settings were only used for formats like "d" or "D". Can you double check that using the above doesn't work on some machines? -nerseus 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
HJB417 Posted February 19, 2004 Posted February 19, 2004 run this on your machine(s) and tell me what is the value of the variable data string data = DateTime.Now.ToString("dd/MM/yyyy"); Quote
bungpeng Posted February 19, 2004 Author Posted February 19, 2004 Nerseus: Last time I also thought like you. But now I can't explain why this thing happen. HJB417: I get the same result: 19-02-2004 The special about my PC is I am using Chinese version of Windows2000 Pro, but this function nothing to do with my Windows version right? Quote
HJB417 Posted February 19, 2004 Posted February 19, 2004 (edited) ok, what about this const int enUS = 0x0409; System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(enUS); string data = DateTime.Now.ToString("dd/MM/yyyy", culture); I'm still unsure but it probably has something to do with it being chinese. It states that "This method uses formatting information derived from the current culture.". On my machine, default is us, and it works correctly. If run the code above, and change the value of enUs to 0x0804 which is the code for Chinese - China, my results are the same as your first post. So it has to do w/ your culture code. Edited February 19, 2004 by HJB417 Quote
bungpeng Posted February 19, 2004 Author Posted February 19, 2004 Problem solved! Thank you very much! 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.