473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Converting Server to Local Time



using System
;using System.Runtime.InteropServices;
public void UpdateTime(DateTime ServerTime)
{
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime localTime = localZone.ToLocalTime(ServerTime);
TimeSpan localOffset = localZone.GetUtcOffset(localTime );
ServerTime = ServerTime.Add(localOffset);
SetTime(ServerTime);
}
[StructLayoutAttribute(LayoutKind.Sequential)]
private struct SYSTEMTIME
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}
[DllImport("kernel32.dll")]
static extern bool SetLocalTime(ref SYSTEMTIME time);

private void SetTime(DateTime NewTime)
{
SYSTEMTIME st;
st.year = (short)NewTime.Year;
st.month = (short)NewTime.Month;
st.dayOfWeek = (short)NewTime.DayOfWeek;
st.day = (short)NewTime.Day;
st.hour = (short)NewTime.Hour;
st.minute = (short)NewTime.Minute;
st.second = (short)NewTime.Second;
st.milliseconds = (short)NewTime.Millisecond;
SetLocalTime(ref st);
}
*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
0 1327

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

Similar topics

4
by: Elie Grouchko | last post by:
Hi All 1. I need to convert the local-time of the server on which I run my website to UTC and I don't want to rely on the server local time and timezone (i.e. I don't want to hardcode the...
0
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. ...
6
by: Jim Davis | last post by:
Before I reinvent the wheel I thought I'd ask: anybody got a code snippet that will convert the common ISO8601 date formats to a JS date? By "common" I mean at the least ones described in this...
8
by: Uttam | last post by:
Hello, I am currently in the process of developing an application in a pure desktop world using Access 2000. I am intending to convert this pure desktop application into a Client Server...
14
by: D | last post by:
Hey guys- not sure where this post fits in, so I cc'd a few other groups as well- hope you dont mind... I have someone creating a database for me in Access 2000 (or is it called XP?). When it's...
29
by: Jan | last post by:
Hi: I have an Access database that's been running (in one form or another) for a couple of different clients for a few years. Now a new client has requested that it be implemented with a SQL...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
3
by: deepeshn | last post by:
Hi people, I have a function which will receive 2 parameters:the date field in GMT time and the user's time zone. I have to return a datetime field in the user's time. the thing is the server...
9
by: jdlists | last post by:
I have inheirted some existing code, that i will explain in a moment, have needed to extend and ultimately should be able to run in threads. I've done a bunch of work with python but very little...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
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...

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.