473,383 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Date/Time problems

Hi guys

I'm having a problem with DateTime.Now.ToShortDateString().

It works fine, but I've got 2 servers (development and production), and
while the production server works perfectly and returns a UK formatted short
date (dd/mm/yyyy), my development server returns the US format (mm/dd/yyyy).

Both servers are Win2k3 with .net2.0 (2.0.50727) and I've checked date/time
settings and regional settings from Control Panel on both servers and they're
exactly the same.

What's going on? Why is DateTime giving US formats? Is there something I
need to change in the .net framework?

Help, this is really annoying!
May 11 '06 #1
2 1413
Are you sure Regional Settings are exacly same?

you can use custom format with
string.Format("dd/mm/yyyy", DateTime.Now)

or
string.Format("dd/MM/yyyy", DateTime.Now)

Hope this helps
--
Galin Iliev [MCSD, MCSD.NET]
Senior Software Developer
www.wordassist.com

"musosdev" <mu*******@community.nospam> wrote in message
news:3C**********************************@microsof t.com...
Hi guys

I'm having a problem with DateTime.Now.ToShortDateString().

It works fine, but I've got 2 servers (development and production), and
while the production server works perfectly and returns a UK formatted
short
date (dd/mm/yyyy), my development server returns the US format
(mm/dd/yyyy).

Both servers are Win2k3 with .net2.0 (2.0.50727) and I've checked
date/time
settings and regional settings from Control Panel on both servers and
they're
exactly the same.

What's going on? Why is DateTime giving US formats? Is there something I
need to change in the .net framework?

Help, this is really annoying!

May 11 '06 #2
Hi,

Thank you for posting!

First, this issue is not directly related with the regional settings in
Control Panel.

One possible cause is related to a new feature in ASP.NET 2.0.

ASP.NET 2.0 has a new feature called 'Auto-Culture Handling': it maps
Accept-Language headers to CultureInfo objects and attaches them to the
current thread, thus altering DateTime.ToShortDateString()'s result.
Auto-culture handling is enabled for individual pages by including
Culture="auto" and UICulture="auto" attributes in the pages' @ Page
directives. It's enabled site-wide by including a <globalization
culture="auto" uiCulture="auto"/> element in web.config.

When this feature is enabled, the user can configure the browser to change
the preferred language and shows different result of
DateTime.ToShortDateString().

If this is not your case, you can always override the default cultureInfo
by setting the culture and uiCulture to "en-GB" either in individual page
or in web.config.
Regards,

Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
5
by: Javier | last post by:
I have a field type Date/Time that automatically defaults to Now(). I'm having a problem writing a query that will retrieve all the records for a specific date the user to enters when prompted. I...
2
by: Riegn Man | last post by:
I have a problem with access and our time clocks. We have time clocks that put out a .log file with the badge swipes for everybody. There is one .log file for each day. I am pulling that data...
7
by: mr.nimz | last post by:
hello, this is antenio. recently i've come to a problem. i got a way through it, somehow, still it left me in a curious state, so i'm posting it here, if i can get an answer from some techy, ...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
2
by: hardik | last post by:
hi friends, i am really surprized the way access behaves in date fields i mean it's all ok when you have us time zone or us servers but if you have diffrent timezone like uk then access creates...
4
by: Simon Gare | last post by:
Hi all, I am trying to retrieve a count of booking entries made 30 days ago, below is the end of the query I am having problems with. dbo.booking_form.TimeOfBooking = DATEADD(day, -30,...
3
by: rn5a | last post by:
In my local computer, date has been set in this format - dd/MM/yyyy. When I insert records in a MS-Access DB table using ASP.NET, then the records get inserted in the Access DB table exactly in the...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.