USAGE of DateTime.GetDateTimeFormats()

  • Thread starter Thread starter Sugandh Jain
  • Start date Start date
S

Sugandh Jain

Hi,



I am using dotnet framework 2.0, visual studio 2005.



We are using DateTime.Now.ToUniversalTime().GetDateTimeFormats()[105] to
format the string in particular format and using parseint64 after that to
generate an id after removing the - and spaces and other things.

Now, on my system

DateTime.Now.ToUniversalTime().GetDateTimeFormats()[105] returns "09-Jan-07
06:50:07 PM"(Un Desirable) while on all other machines in our project this
returns in the format "2007-01-09 18:50:07". (Desirable Format)

How to ensure that the same value is returned in all the machines?

Regards,

Sugandh
 
Not sure how to ensure the date time format is returned the same but I think
your difference in date time format is likely to be the locale settings on
the systems being different.
 
I normally do something like this, the format never changes. You should be
able to do the same with universal time.

DateTime.Now.ToString("yyyyMMddhhmmssffffff");

Regard,
John
 
What you have told is a nice way. but this is taking hour in 12 hour format,
but I want it in 24 hour format, because I have to it to generate ID's which
always increase in value.
How to use it in 24 hr Format does not help..
making "hh" to "hhhh"

Regards,
Sugandh

John J. Hughes II said:
I normally do something like this, the format never changes. You should
be able to do the same with universal time.

DateTime.Now.ToString("yyyyMMddhhmmssffffff");

Regard,
John

Sugandh Jain said:
Hi,



I am using dotnet framework 2.0, visual studio 2005.



We are using DateTime.Now.ToUniversalTime().GetDateTimeFormats()[105]
to format the string in particular format and using parseint64 after that
to generate an id after removing the - and spaces and other things.

Now, on my system

DateTime.Now.ToUniversalTime().GetDateTimeFormats()[105] returns
"09-Jan-07 06:50:07 PM"(Un Desirable) while on all other machines in our
project this returns in the format "2007-01-09 18:50:07". (Desirable
Format)

How to ensure that the same value is returned in all the machines?

Regards,

Sugandh
 
hh = 12 hour time
HH = 24 hour time

Regards,
John

Sugandh Jain said:
What you have told is a nice way. but this is taking hour in 12 hour
format, but I want it in 24 hour format, because I have to it to generate
ID's which always increase in value.
How to use it in 24 hr Format does not help..
making "hh" to "hhhh"

Regards,
Sugandh

John J. Hughes II said:
I normally do something like this, the format never changes. You should
be able to do the same with universal time.

DateTime.Now.ToString("yyyyMMddhhmmssffffff");

Regard,
John

Sugandh Jain said:
Hi,



I am using dotnet framework 2.0, visual studio 2005.



We are using DateTime.Now.ToUniversalTime().GetDateTimeFormats()[105]
to format the string in particular format and using parseint64 after
that to generate an id after removing the - and spaces and other things.

Now, on my system

DateTime.Now.ToUniversalTime().GetDateTimeFormats()[105] returns
"09-Jan-07 06:50:07 PM"(Un Desirable) while on all other machines in our
project this returns in the format "2007-01-09 18:50:07". (Desirable
Format)

How to ensure that the same value is returned in all the machines?

Regards,

Sugandh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top