usage to datetime.ToString("yyyyMMddhhmmssffffff");

S

Sugandh Jain

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
 
C

Christof Nordiek

Hi Sugandh,

use "HH" for 24 hour format.

hth
Christof

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
 
D

DeveloperX

Capitalise the hh as in the following:
Console.WriteLine(
DateTime.Now.AddHours(10).ToString("yyyyMMddHHmmssffffff"));

Sugandh 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
 
S

Sugandh Jain

I Got my answer.
using HH returns in 24 hours format instead of hh.

Thanks.


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

Top