Click to See Complete Forum and Search --> : DateTime Problem


kwilliams
03-12-2008, 11:43 AM
I'm using the following code to pull the current date in mm/dd/yyyy format:
Dim dtCurrDate As DateTime = DateTime.Now 'Assign current date

On the test server, 03/12/2008 11:25:50 AM is returned, and the date is formatted properly (mm/dd/yyyy). But on the web server, 3/12/2008 11:25:50 AM is returned and the date is not formatted properly (m/dd/yyyy). My Network Administrator made sure to change the date format on the server from m/dd/yyyy to mm/dd/yyyy, but it didn't fix the problem when I re-loaded the page. Both servers are running ASP.NET 2.0. What could be causing this problem?

TheBearMay
03-12-2008, 12:19 PM
I just always assume that the date won't be formatted the way I want and format it myself:


Dim sDate As String
sDate = dtCurrDate.toString("MM/dd/yyyy hh:mm:ss tt")