microkarl
Well-known member
Hello all,
I have a question about convert strings into dataTime format (in a globalization manner). Consider I have the following code:
The code would work and return "12/30/2005" if we are using United Sates DateTime Format (Regional Settings in Control Panel). However, if we choose some other culture, say Britsh, their regional datetime string format is "DD/mm/yyyy", so the above code would crash because CDate() converts a string to datetime based on the setting from the regional settings. So, my question is that is there any graceful way to handle situation like this easily?
I did some research on Google but I found out theres no single function to do it, or maybe I am missing somthing... Please let me know if you guys have any solutions...
Thanks,
Carl
I have a question about convert strings into dataTime format (in a globalization manner). Consider I have the following code:
Code:
Dim strMonth As String = "12"
Dim strDay As String = "30"
Dim strYear As String = "2005"
strTime = strMonth & "/" & strDay & "/" & strYear
dtmTime = CDate(strTime)
dtmTime.ToString("MM/dd/yyyy")
The code would work and return "12/30/2005" if we are using United Sates DateTime Format (Regional Settings in Control Panel). However, if we choose some other culture, say Britsh, their regional datetime string format is "DD/mm/yyyy", so the above code would crash because CDate() converts a string to datetime based on the setting from the regional settings. So, my question is that is there any graceful way to handle situation like this easily?
I did some research on Google but I found out theres no single function to do it, or maybe I am missing somthing... Please let me know if you guys have any solutions...
Thanks,
Carl