How can i change System DateTime Programetically.
How can i change my System DateTime Programetically.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Jun 29, 2010, 2:31 AM EDT
hello ankur
i think you can do that with hte help of kernal32.dll api.
you need to import this like
and use SetSystemTime function forchange the system date.
thanks
Please mark as answer if it helps
Abhimanyu K VatsaRank #14 · 51.7K reputationPosted Jun 2, 2010, 5:44 AM EDT
as i know c# or asp.net or php or coldfusion are web based programming languages and it is not possible to change the date and time via thease all languages. one main reason would be 'web languages are not console based language'. only console based application languages can change the date and time of system. basically from DOS or vb etc.
good luck
Ankur GuptaRank #1,017 · 1.9K reputationPosted Jun 2, 2010, 8:52 PM EDT
Damodar29 reputationPosted Jul 9, 2010, 9:16 AM EDT
try this to change ur system time..
public struct SYSTEMTIME
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool SetSystemTime( [In] ref SYSTEMTIME st );
If you want to change the time zone in your system here is the code sample
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/fa563f41-344c-465d-bfbe-1859299d2491/