little help for Date/Time

  • Thread starter Thread starter vinnie
  • Start date Start date
V

vinnie

I have a layer at the top of a page, and i wish to show something like
this:

Today is "Day", "Month" "Year", and the exact hour is "hh" "mm" "ss"

Any idea how to do that? I working with C# - ASP 2.0

Thanks
 
vinnie,

Well, the DateTime structure has a static Now property which you can use
to get the current date/time. From that DateTime instance, you can access
the Day, Month, and Year properties on the structure.

You can also get the TimeSpan instance corresponding to the time with
the TimeOfDay property. The TimeSpan instance has Hours, Minutes, and
Seconds properties to get those values.

Then it's just a simple matter of outputting it to the page, which you
can do with calls to Response.Write.

Be aware that since this is a web application, the person that is
browsing the page might be in a different location than you, and have a
different time.
 
Nicholas said:
Be aware that since this is a web application, the person that is
browsing the page might be in a different location than you, and have a

If it's designated as being run on the server, this is a non-issue.


Chris.
 
It's because it is run on the server that it is an issue. For example,
if you have a person in NYC browsing a page that is hosted on a server that
is in LA, DateTime.Now will return (and the subsequent code will print) the
time from LA (assuming the machine is set for that time zone). The person
in NYC will see a time that is three hours behind what the clock on their
desk is.

The point is that some distinction should be made to what the local time
offset is, or adjust for the location of the client (if possible).
 
Nicholas said:
It's because it is run on the server that it is an issue. For example,
if you have a person in NYC browsing a page that is hosted on a server that
is in LA, DateTime.Now will return (and the subsequent code will print) the
time from LA (assuming the machine is set for that time zone). The person
in NYC will see a time that is three hours behind what the clock on their
desk is.

Ah, I took your statement to mean something different.
The point is that some distinction should be made to what the local time
offset is, or adjust for the location of the client (if possible).

Agreed.


Chris.
 
It's because it is run on the server that it is an issue. For example,
if you have a person in NYC browsing a page that is hosted on a server that
is in LA, DateTime.Now will return (and the subsequent code will print) the
time from LA (assuming the machine is set for that time zone). The person
in NYC will see a time that is three hours behind what the clock on their
desk is.

The point is that some distinction should be made to what the local time
offset is, or adjust for the location of the client (if possible).

So, in case i need to change the name of the weekdays and months from
english into another language, i should i do that?
 
vinnie,

It's up to you, and how wide-reaching your plan your site on being, and
the audience you are appealing to.
 

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

Similar Threads


Back
Top