473,804 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I get the user DateTime

Hi;

When I get a request how can I get the user's local DateTime? I can get
ultureInfo.Curr entUICulture.Ca lendar for a calendar but I don't see any way
to turn that in to a DateTime (although you would think that would be
possible).

Also, is there any way to set IE to have a different timezone than my system
to test this on my system (so IE is set to pacific time but my "server" is on
mountain time)?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Oct 26 '06 #1
7 6226
hejdig.

Ge information about the client's (IE's) time through javascript and insert
this into a hidden field.
Look at this field by the next posting to find out whatever you need.
Normally time is incremented/decremented in whole hours and by comparing the
server's time and hope the client's clock is adjusted you could find out the
time zone. (If this is what you are looking for)
If there is any other way to find out the TZ for the client through
javascript please look into http://javascript.faqts.com/ . You could for
instance find the difference between the UTC and the local time through
javascript.

For setting different timezones client/server on the same machine. The
easiest way would be to borrow a machine from someone - anything that runs
your browsers would do. A slightly more expensive (time wise) solution
would be to install a virtual pc on the same machine.
Or use WMWares solutions where you run a Linux OS in a virtual machine. You
can still play around with the timezone just as easy.

HTH

/OF

"David Thielen" wrote
When I get a request how can I get the user's local DateTime? I can get
ultureInfo.Curr entUICulture.Ca lendar for a calendar but I don't see any
way
to turn that in to a DateTime (although you would think that would be
possible).
Also, is there any way to set IE to have a different timezone than my
system
to test this on my system (so IE is set to pacific time but my "server" is
on
mountain time)?

Oct 26 '06 #2
Hi;

The problem with javascript is I need this information when creating the
page, not when processing the submit. So if they come to the page I need this
on first, no javascript has run yet and therefore there is no way to get the
info.

Doesn't this get passed in the header request somewhere?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Oct 26 '06 #3
I understand you need this information before postback, therefore you cannot
use javascript. You may use Request.UserLan guages to obtain user preffered
language

if (!IsPostBack)
{
const string DefaultLanguage Code = "en-GB";

string[] languages = Request.UserLan guages;
string code = DefaultLanguage Code;
System.Globaliz ation.CultureIn fo cultureInfo;

if (languages != null && languages.Lengt h 0)
{
code = languages[0];
}
}

Then the real deal begins. There is no standard function in ASP.NET to
retrive all timezones (but this feature will be available in the next version
3.0 of .NET). There is of course System.TimeZone class, but you can read just
the local, server zone information To populate all the timeones you could use
WinAPI - don't worry it's not difficult,
http://www.michaelbrumm.com/simpletimezone.html), then match language code
with timezone.

hope this helps
--
Milosz Skalecki
MCP, MCAD
"David Thielen" wrote:
Hi;

The problem with javascript is I need this information when creating the
page, not when processing the submit. So if they come to the page I need this
on first, no javascript has run yet and therefore there is no way to get the
info.

Doesn't this get passed in the header request somewhere?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Oct 27 '06 #4
Hi;

For the UK that would work ok. But for the US (or Russia), there is a very
large number of timezones. Isn't there something in the request header that
lists the GMT offset of the requesting browser?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Milosz Skalecki" wrote:
I understand you need this information before postback, therefore you cannot
use javascript. You may use Request.UserLan guages to obtain user preffered
language

if (!IsPostBack)
{
const string DefaultLanguage Code = "en-GB";

string[] languages = Request.UserLan guages;
string code = DefaultLanguage Code;
System.Globaliz ation.CultureIn fo cultureInfo;

if (languages != null && languages.Lengt h 0)
{
code = languages[0];
}
}

Then the real deal begins. There is no standard function in ASP.NET to
retrive all timezones (but this feature will be available in the next version
3.0 of .NET). There is of course System.TimeZone class, but you can read just
the local, server zone information To populate all the timeones you could use
WinAPI - don't worry it's not difficult,
http://www.michaelbrumm.com/simpletimezone.html), then match language code
with timezone.

hope this helps
--
Milosz Skalecki
MCP, MCAD
"David Thielen" wrote:
Hi;

The problem with javascript is I need this information when creating the
page, not when processing the submit. So if they come to the page I need this
on first, no javascript has run yet and therefore there is no way to get the
info.

Doesn't this get passed in the header request somewhere?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Oct 27 '06 #5
Hi Dave,

So far I haven't found any standard httpheader(most browser will use) to
send client-side timezone info. And yes, use timezone API to query the
timezone from a given language/culture is not quite easy.

IMO, I think you may consider such a workaround solution:

** create a helper server page in your application which embeded client
script to get the client time-zone offset info and postback to server.

** your server-side will get the timezone info and store it in
cache(session or profile) for the current user

** for each user, you may redirect it to the helper page first (if there is
no timezone info in the certain cache storage)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 27 '06 #6
I can't find anything either. It's amazing that they haven't added that to
the standard request header yet...

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Steven Cheng[MSFT]" wrote:
Hi Dave,

So far I haven't found any standard httpheader(most browser will use) to
send client-side timezone info. And yes, use timezone API to query the
timezone from a given language/culture is not quite easy.

IMO, I think you may consider such a workaround solution:

** create a helper server page in your application which embeded client
script to get the client time-zone offset info and postback to server.

** your server-side will get the timezone info and store it in
cache(session or profile) for the current user

** for each user, you may redirect it to the helper page first (if there is
no timezone info in the certain cache storage)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 27 '06 #7
I think at that time the Timezone inforamtion is not considered so critical
to include in http specification. Anyway, so far we haven't any better
means to directly get the accurate timezone info in the first http request
to our web page. Do you think using a help page may help? Also, you may
also put some AJAX script in your default page to collect such information
and update it to server-side(cache) without postback.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 27 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1255
by: Nemo | last post by:
I have problem to get my dates from my user control. The problems is that the datetimes sets after when I get the values from my aspx page. Here is how my user control lock likes. private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack)
5
6017
by: David C. Barber | last post by:
I'm trying to determine which user has locked a given record from VB6. I know I can use sp_lock and sp_who, and match up the data to determine which users have locked records in my database, however I haven't seen a way to match the specific user to the specific record. What am I missing here? Thanks! *David*
3
6176
by: teddysnips | last post by:
In the script below is the DDL to create some tables and a UDF. What I'm interested in is the UDF at the end. Specifically, these few lines: --CLOSE OTRate --DEALLOCATE OTRate ELSE -- @NumRecords <= 0 If I uncommment CLOSE and DEALLOCATE and check the syntax I get a
0
1926
by: Chris Millar | last post by:
I have a user control that i wish to extend to change the date when the user selects the numeric up down button. The code explains itself, hope someone can help. any ideas appreaciated.. Chris. code :
1
1528
by: Green | last post by:
Hi, All I need to dynamically load a user control and change some properties on the user control, and display in the aspx page. Unfortunately I failed, nothing appears. Please help me look at, thanks. Comment c = (Comment) Page.LoadControl("Comment.ascx"); Label time = new Label();
1
1140
by: Asad | last post by:
Hi, I was wondering how I can find out the time user takes on an aspx page before hitting a submit button. Since there is that whole server-side vs. client-side issue, I was thinking I can store the current time in a variable on server side, and when the user hits submit, inside the method invoked I take the difference of the time now and the previously stored time. It all makes sense right? And I'm new with ASP.NET coding, so I'd
3
1243
by: Raterus | last post by:
Hi, I have a business object that exposes a DateTime object to my presentation layer. Usually this is filled with a valid date, but sometimes it is empty (and stored as 1/1/1900 as it is a SmallDateTime in SQL Server). I'm unsure how best to present this to the user, I want no date to appear if it is blank "1/1/1900", but if it is a valid date, show it. I guess I'm a little confused as to which layer should do this, my first hunch is the...
0
905
by: Matt | last post by:
Have this ASPNET Applcation on dev server. On WindowsAuthentication_OnAuthenticate Getting the user id from database and matching with windows auth user id, if match assign to mUserIdentity get from authtickets and add to Current http context. Problem is.. when couple people hit the site on server they all getting the same userID displayed.. What am i doing wrong...
2
2070
by: Mark | last post by:
Hi. I am making a user control right now, and it looks something like this: <script runat="server"> public string SelectCommand { set { // see below for why the following line is here.
1
4973
by: Tamer Ibrahim | last post by:
Hi, I'm trying to validate user input date using range validator on a text box . This code is throwing this exception "The value 'DateTime.Now;' of the MaximumValue property of 'rvQDate' cannot be converted to type 'Date'. " <asp:TextBox ID="txtQDate" runat="server" Enabled="False"></asp:TextBox>
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.