I am using the following piece of code in my application
when I execute in my local system it is giving me proper date but when this code is executing in a different production server then the date value is not constant it keeps on changing on the same day. I am a bit confused what could be the reason.
If by different you mean correct date but in a different format (other than MM/dd/yyyy),
try skipping locale.
There is no need for the locale, by default I guess, the language must be English or as set on the server.
when I execute in my local system it is giving me proper date but when this code is executing in a different production server then the date value is not constant it keeps on changing on the same day
Also, if the date difference is not big, say today is 17 and date changes to 18 or 16 , then it may be the problem with locale, otherwise you have to explain it little more. like what is the default locale of your production server ?, is the date correct there ? where you're executing this code ?
Also, I am sure you will be aware - but just in case missed: make sure that the time difference is not due to the clock time differences (if the production server is located at another country/region). I mean the local time.
Please make sure that the timezones are correct which you are referring to. Also check it after say a couple of hours cause currently certain locations in US are still with 17 August 2009.
Also, to have a proof, see what's present JR time is, at the time of posting, the JR servers (which is located in Atlanta, if I'm correct, because of the recent server shift) time is this:
All times above are in your local time zone & format.The current ranch time (not your local time) is Aug 18, 2009 00:37:28.
It means, just before 37 minute, the date is 17 August 2009, while in India, we had 18 August afternoon, at the same time