modify/change system date time c#

Hello community, i researched and tried the below code but it is not working, it shows no error. The reason i want to modify the time is that the user should be the one validating the time and not the time zone from web which automatically sets the date and time. below is the code i tried, code in c#. thanks in advance.

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using System;
using System.Collections.Generic;

namespace SetSystemTime {

public class DateTimeValidator : MonoBehaviour {
    [StructLayout(LayoutKind.Sequential)]
    public struct SYSTEMTIME {
        public ushort wYear;
        public ushort wMonth;
        public ushort wDayOfWeek;
        public ushort wDay;
        public ushort wHour;
        public ushort wMinute;
        public ushort wSecond;
        public ushort wMilliseconds;
    }

    [DllImport("kernel32.dll", EntryPoint = "GetSystemTime", SetLastError = true)]
    public extern static void Win32GetSystemTime(ref SYSTEMTIME sysTime);

    [DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
    public extern static bool Win32SetSystemTime(ref SYSTEMTIME sysTime);

    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    internal static extern bool SetLocalTime(ref SYSTEMTIME lpSystemTime);

    [DllImport("kernel32.dll")]
    public extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);

    public void SetCompTime() {
        SYSTEMTIME getStime = new SYSTEMTIME();
        Win32GetSystemTime(ref getStime);

        SYSTEMTIME updatedTime = new SYSTEMTIME();
        getStime.wYear = (ushort)2009;
        getStime.wMonth = (ushort)1;
        getStime.wDayOfWeek = (ushort)1;
        getStime.wDay = (ushort)1;
        getStime.wHour = (ushort)0;
        getStime.wMinute = (ushort)0;
        getStime.wSecond = (ushort)0;
        getStime.wMilliseconds = (ushort)0;
        Win32SetSystemTime(ref getStime);
        //SetLocalTime(ref getStime);
        //SetSystemTime(ref getStime);
    }

    public void GetTime() {
        SYSTEMTIME getStime = new SYSTEMTIME();
        Win32GetSystemTime(ref getStime);

        Debug.Log(System.DateTime.UtcNow.ToString() + "Current Time: " +
            getStime.wHour.ToString() + ":"
            + getStime.wMinute.ToString());
    }

    void Start() {
        SetCompTime();
    }
}

}

Maybe this question is to old. But I think some one still need the answer :slight_smile:
The above code still working, but you must run Unity as administrator

Tested:
Unity 2018.3.0
Windows 10