473,785 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting DateTime with an offset

I have an application that stores all DateTime inforamtion in UTC.
However, this application will be accessed from arround the world. I
would like my users to be able to specify their prefered TimeZone.
>From then on, i would like all DateTime information to be displayed in
their timezone.

I have written the code to do the timezone conversion. Now what
remains is finding a way to make every DateTime display in my
application use this code and get converted. I've tried to use the
culture info, the DateTimeFormatI nfo class, i've even tried to make my
own custom formatter. No matter what I do, I can't seem to get my
DateTime.ToStri ng() to go through my conversion code.

I have a lot of web pages, going through every page and every grid and
manually making a conversion would be tedious and prone to error. I'd
rather have DateTime.ToStri ng go through some kind of formatting that
i am completely in control over and then i can do my formatting and
converting there.
Any help?

Jun 15 '07 #1
1 1641
DateTime a is sealed value type so you can not extend it. You will have
to write a class that encapsulates it. then its ToString() can do what
you want.

-- bruce (sqlwork.com)
Untitled wrote:
I have an application that stores all DateTime inforamtion in UTC.
However, this application will be accessed from arround the world. I
would like my users to be able to specify their prefered TimeZone.
>>From then on, i would like all DateTime information to be displayed in
their timezone.

I have written the code to do the timezone conversion. Now what
remains is finding a way to make every DateTime display in my
application use this code and get converted. I've tried to use the
culture info, the DateTimeFormatI nfo class, i've even tried to make my
own custom formatter. No matter what I do, I can't seem to get my
DateTime.ToStri ng() to go through my conversion code.

I have a lot of web pages, going through every page and every grid and
manually making a conversion would be tedious and prone to error. I'd
rather have DateTime.ToStri ng go through some kind of formatting that
i am completely in control over and then i can do my formatting and
converting there.
Any help?
Jun 15 '07 #2

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

Similar topics

0
5162
by: Symon R | last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm hoping someone out there can disprove my findings and tell me where I've gone wrong! I have designed a web service that accepts messages from .NET clients. The web method call includes an object as one of it's parameters - this reflected object has been given a property called "FutureDelivery" and expects a DateTime value. The clients may be in different timezones...
2
7292
by: BjörnHolmberg | last post by:
Hi everyone! In the following code we get a UTC offset in xml. Since I want my WAP users in UTC+02:00 to see data on a server in some US time zone, a lot of confusion will be created from this behavior. Either I use .NET logic on the server and get server local time or I create xhtml pages directly from serialized objects. Eitherway I'll have to write my own logic to take care of utc offset. Is it possible to override XmlSerializer so...
2
12726
by: Sterling Ledet | last post by:
I am trying to create a web service that takes a string from my web server in the following format: Mon, 6 Oct 2003 18:39:47 UTC and put's in a datetime so it can then be reformatted in C# as necessary for variuos purposes. There is something wrong with the following code. I get the following error when I enter in the above date string:
9
4929
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="urn:JadeWebServices/WebServiceProvider/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
2
2179
by: JC Voon | last post by:
hi: Is there a function to format the datetime value to the following format 2005-09-29T17:57:03.0000000+08:00 ? currently i'm using a hard way Dim result As String
3
8341
by: asanford | last post by:
I want to create a web service that allows the caller to pass a DateTime to the web service (that is, create a web method such as void MyWebMethod(DateTime dt).) However, I want to be able to capture the TimeZone of the caller as well - but I don't want the interface to specify an xs:string as the method argument - I want it to use an xs:dateTime type argument. Now, I know when a DateTime structure is serialized into XML it becomes an...
0
1382
by: David Pratt | last post by:
Hi. I am creating a couple of small methods to help me manage time from UTC as standard but I am getting strange results. If I start with a datetime of 2005-12-12 14:30:00 in timezone 'America/Halifax' and I want to turn this into a UTC representation. from datetime import datetime from pytz.reference import UTC import pytz
4
8336
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the date column always shows the date and time while I just want the short date. I have tried applying a format string {0:d} but to no avail. I saw a lot of posts regarding the htmlencode property but I do not know how to turn that off for a...
4
3175
by: chandy | last post by:
Hi, I have a datetime+offset as a string and want to get two datetimes from it; the local and UTC. So far I can only do it by splitting on the + or - of the offset and creating a new date with and without the offset. Is there a cleaner way, i.e., using System.DateTime etc. and not resorting to string splitting? I had read about DateTimeOffset which seems ideal but this is an ASP.Net 2.0 app and that seems to be only in Framework 3.5...
0
9480
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
10319
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...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
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
9947
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
6737
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
5380
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4046
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 we have to send another system
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.