Jump to content

DateTime Problem

Recommended Posts

I'm using the following code to pull the current date in mm/dd/yyyy format:Dim dtCurrDate As DateTime = DateTime.Now 'Assign current dateOn 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?

Share this post

Link to post
Share on other sites

When you want to convert your DateTime object into a string, you can pass a format string to tell .NET how to build the date string.In C#

DateTime dtCurrDate = DateTime.Now;Response.Write(dtCurrDate.ToString("MM/dd/yyyy HH:mm:ss tt"));

Check out this great page for different date format string options:http://authors.aspalliance.com/aspxtreme/a...s.aspx?pageno=3

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...