473,511 Members | 15,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem Displaying Server Timezone DateTime To Client Timezone DateTime

View Poll Results: Best Method to solve timezone conversion
javascript 0 0%
code behind 0 0%
Voters: 0. You may not vote on this poll

4 New Member
Hi All,

I have one web site and server that is hosted on "Pacific Standard Time" Zone .
When a user from different contries creat blogs the displayed time for respective blog will be a server time..
the code below is what i am using for conversion..

TimeZoneInfo PTZone = TimeZoneInfo.FindSystemTimeZoneById( "Pacific Standard Time" );

lbl_createonvalue.Text = TimeZoneInfo.ConvertTime( DateTime.Parse( incident.CreatedOn.ToString() ), PTZone, TimeZoneInfo.Local ).ToString( "MM/dd/yyyy" );


But i want Date Time to be displayed on respective timezones.

Is there any Javascript that can handel conversion at client side or any other code that works good for my scenario

Can any one help out from this..
Jun 16 '09 #1
4 7870
Frinavale
9,735 Recognized Expert Moderator Expert
Since JavaScript works in the client's browser it will be able to detect the user's current time.

Use JavaScript to set a the value of HiddenField with the date/time information. The server will be able to access the HiddenField and can save the blog information accordingly.

Just be aware that the client's computer might have invalid information (the time could be wrong etc)...and you should always validate any input coming from the browser (the end user might have malicious intent and provide something other than a date in the HiddenField that may cause damage to your site).
Jun 16 '09 #2
reach2raziq
4 New Member
In my application i am not saving the blog created time. datetime is automatically handled by crm server.. just while populating those information on to client browser, i want to display it in client timezone.
Jun 17 '09 #3
Frinavale
9,735 Recognized Expert Moderator Expert
You going to have to use JavaScript to determine the client's time zone....and somehow pass that information to the server (using a HiddenField or Cookie or something).

The JavaScript getTimeZoneOffset() method will return you the difference in minutes between Greenwich Mean Time (GMT) and client's local time. You can use this information on the server to determine what time should be displayed.

Or you could simply do this in JavaScript.
Use JavaScript to retrieve the date/time value returned by the server, use JavaScript to calculate the Greenwich Mean time, use JavaScript to adjust the date/time value accordingly. The only thing is that the JavaScript method is going to have to know what time zone the Server is in.

So yeah, there's more than one way to solve this problem.
Pick one and give it a try :)
Jun 17 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1434
by: pduncan | last post by:
Hi all, I need to update client machines with the correct time if it is inaccurate. The server I'm using will always have the correct time so I'll be using that as the source of correct time. ...
1
3785
by: James | last post by:
I need to import a bunch of data into our database for which there's a single entry each day which occurs at the same time every day in local time - so I need to convert this to UTC taking into...
5
7245
by: Iwan Petrow | last post by:
Hi, I have Win application -> Web service -> Sql Server. The user input date and time in format dd/MM/yy hh:mm. I convert it to datetime and send it to a web service which save it to the db. But...
5
3411
by: thomasamillergoogle | last post by:
I am building a .net client application that will be deployed world wide. The client can schedule reminders. To do this the user picks the datetime he wants the reminder sent, _I convert the...
5
2582
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
10
4754
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
9
9342
by: Abhishek | last post by:
Hi I am trying to deserialize/ Parse a datetime object with the below string "2007-05-14T08:00:00.000+02:30" . If i am in GMT + 2.30 time zone everything's fine however if i am in GMT + 5.30 i...
5
1328
by: Alexander Vasilevsky | last post by:
Need to display the date of the customer, in accordance with its Time zone http://www.alvas.net - Audio tools for C# and VB.Net developers + Christmas gift
7
1803
by: Looch | last post by:
All, I'm using a WinForm app that calls methods on a remotable object. The app server hosting the object is in New York. Using the same exact application, a Sql Server 2005 datetime column's...
0
7251
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,...
0
7367
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,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
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...
0
7517
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...
0
5673
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,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
790
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.