Current System Time?
Okay, I'm gonna feel really dumb when I get the answer to this, but here
goes...
I found System.Environment.TickCount, but I'm wondering if anyone has seen
any other ways to get some sense of time in C#.
[230 byte] By [
Oscar] at [2007-11-9 18:21:25]

# 1 Re: Current System Time?
This will print out the current date/time:
using System;
class testTime
{
public static void Main()
{
Console.WriteLine(DateTime.Now);
}
}
System.DateTime has a lot of other Date/Time related members.
"Oscar" <consulBanana@hotmail.com> wrote in message
news:39937683@news.dev-archive.com...
> Okay, I'm gonna feel really dumb when I get the answer to this, but here
> goes...
>
> I found System.Environment.TickCount, but I'm wondering if anyone has seen
> any other ways to get some sense of time in C#.
>
>
# 2 Re: Current System Time?
*SMACK*
*SMACK*
*SMACK*
I think I could break my desk in half that way. Thank you very much for
answering a really, really dumb question. Would you believe I'm actually
using the DateTime class and was looking under _methods_ rather than
_properties_? I must have browsed right past that darned thing half a
dozen times by now.
Most humbly,
Oscar
"Gus Perez [MSFT]" <gusperez@no.spam.please.microsoft.com> wrote in message
news:39938085$1@news.dev-archive.com...
> This will print out the current date/time:
>
> using System;
>
> class testTime
> {
> public static void Main()
> {
> Console.WriteLine(DateTime.Now);
> }
> }
>
> System.DateTime has a lot of other Date/Time related members.
>
>
> "Oscar" <consulBanana@hotmail.com> wrote in message
> news:39937683@news.dev-archive.com...
> > Okay, I'm gonna feel really dumb when I get the answer to this, but here
> > goes...
> >
> > I found System.Environment.TickCount, but I'm wondering if anyone has
seen
> > any other ways to get some sense of time in C#.
> >
> >
>
>
Oscar at 2007-11-11 22:30:28 >

# 3 Re: Current System Time?
Nice one, but it's in US format.
My Locale is setup for UK - output was:
08/14/2000 13:48:00
- Dear I say it, but I'm a VB man (Doh!) - trying to be converted (see:
http://csharpindex.com/authors/matt/ ) A VB NOW returns the format as
configured by the user's Locale settings.
Do you know if is it possible to get the output in non US format, or do we
have to write code to convert?
Matt Searle
http://csharpindex.com
"Gus Perez [MSFT]" <gusperez@no.spam.please.microsoft.com> wrote in message
news:39938085$1@news.dev-archive.com...
> This will print out the current date/time:
>
> using System;
>
> class testTime
> {
> public static void Main()
> {
> Console.WriteLine(DateTime.Now);
> }
> }
>
> System.DateTime has a lot of other Date/Time related members.
>
>
> "Oscar" <consulBanana@hotmail.com> wrote in message
> news:39937683@news.dev-archive.com...
> > Okay, I'm gonna feel really dumb when I get the answer to this, but here
> > goes...
> >
> > I found System.Environment.TickCount, but I'm wondering if anyone has
seen
> > any other ways to get some sense of time in C#.
> >
> >
>
>
# 4 Re: Current System Time?
I don't know if this is actually what you're looking for, but I stumbled
upon the System.Globalization("Spelled with a z?", I hear you ask :) )
Namespace. It's got some pretty funky sounding calanders in there, and
there might be something to do the conversion.
"Matt Searle" <matt@8001dotcom> wrote in message
news:3997ea0b@news.dev-archive.com...
> Nice one, but it's in US format.
>
> My Locale is setup for UK - output was:
> 08/14/2000 13:48:00
>
> - Dear I say it, but I'm a VB man (Doh!) - trying to be converted (see:
> http://csharpindex.com/authors/matt/ ) A VB NOW returns the format as
> configured by the user's Locale settings.
>
> Do you know if is it possible to get the output in non US format, or do we
> have to write code to convert?
>
> Matt Searle
> http://csharpindex.com
>
>
> "Gus Perez [MSFT]" <gusperez@no.spam.please.microsoft.com> wrote in
message
> news:39938085$1@news.dev-archive.com...
> > This will print out the current date/time:
> >
> > using System;
> >
> > class testTime
> > {
> > public static void Main()
> > {
> > Console.WriteLine(DateTime.Now);
> > }
> > }
> >
> > System.DateTime has a lot of other Date/Time related members.
> >
> >
> > "Oscar" <consulBanana@hotmail.com> wrote in message
> > news:39937683@news.dev-archive.com...
> > > Okay, I'm gonna feel really dumb when I get the answer to this, but
here
> > > goes...
> > >
> > > I found System.Environment.TickCount, but I'm wondering if anyone has
> seen
> > > any other ways to get some sense of time in C#.
> > >
> > >
> >
> >
>
>
Oscar at 2007-11-11 22:32:31 >

# 5 Re: Current System Time?
Matt, I've investigated this a bit more and spoken to the developer who
works in this area and have found out a few things I wasn't aware of myself:
- The original code I posted works but is not the correct way of displaying
the date and time. Doing a Console.WriteLine(DateTime.Now) actually calls
the ToString() method which is designed to not use CultureInfo. The
correct way (which will work with your machine's settings) is to call
Console.WriteLine(DateTime.Now.Format("G")); (or one of the other DateTime
formats)
- We seem to use Console.WriteLine(DateTime.Now) to display the date/time
but for debugging output (using InvariantCulture).
- In the PDC drop, doing a Console.WriteLine(DateTime.Now) did print in a
US-English format. That has been changed in newer drops and has adopted an
ISO standard formatting (yyyy-MM-ddThh:mm:ss). Either way, this should not
be used for anything other than maybe debugging.
In summary, in order to format something for display to the user, you should
always call the Format method.
Hope that clears things up...
"Matt Searle" <matt@8001dotcom> wrote in message
news:3997ea0b@news.dev-archive.com...
> Nice one, but it's in US format.
>
> My Locale is setup for UK - output was:
> 08/14/2000 13:48:00
>
> - Dear I say it, but I'm a VB man (Doh!) - trying to be converted (see:
> http://csharpindex.com/authors/matt/ ) A VB NOW returns the format as
> configured by the user's Locale settings.
>
> Do you know if is it possible to get the output in non US format, or do we
> have to write code to convert?
>
> Matt Searle
> http://csharpindex.com
>
>
> "Gus Perez [MSFT]" <gusperez@no.spam.please.microsoft.com> wrote in
message
> news:39938085$1@news.dev-archive.com...
> > This will print out the current date/time:
> >
> > using System;
> >
> > class testTime
> > {
> > public static void Main()
> > {
> > Console.WriteLine(DateTime.Now);
> > }
> > }
> >
> > System.DateTime has a lot of other Date/Time related members.
> >
> >
> > "Oscar" <consulBanana@hotmail.com> wrote in message
> > news:39937683@news.dev-archive.com...
> > > Okay, I'm gonna feel really dumb when I get the answer to this, but
here
> > > goes...
> > >
> > > I found System.Environment.TickCount, but I'm wondering if anyone has
> seen
> > > any other ways to get some sense of time in C#.
> > >
> > >
> >
> >
>
>
# 6 Re: Current System Time?
Great! thanks for your response.
--
Matt Searle
C# Index to resources
http://csharpindex.com
"Gus Perez [MSFT]" <gusperez@pleasenospam.microsoft.com> wrote in message
news:39999406$1@news.dev-archive.com...
> Matt, I've investigated this a bit more and spoken to the developer who
> works in this area and have found out a few things I wasn't aware of
myself:
>
> - The original code I posted works but is not the correct way of
displaying
> the date and time. Doing a Console.WriteLine(DateTime.Now) actually calls
> the ToString() method which is designed to not use CultureInfo. The
> correct way (which will work with your machine's settings) is to call
> Console.WriteLine(DateTime.Now.Format("G")); (or one of the other DateTime
> formats)
> - We seem to use Console.WriteLine(DateTime.Now) to display the date/time
> but for debugging output (using InvariantCulture).
> - In the PDC drop, doing a Console.WriteLine(DateTime.Now) did print in a
> US-English format. That has been changed in newer drops and has adopted
an
> ISO standard formatting (yyyy-MM-ddThh:mm:ss). Either way, this should
not
> be used for anything other than maybe debugging.
>
> In summary, in order to format something for display to the user, you
should
> always call the Format method.
>
> Hope that clears things up...
>
<snip>
