how to change system time on metro style applications developed by javascript? RRS feed

  • Question

  • how can I change system time on metro style applications by JavaScript,just like the usage in c++:
    BOOL WINAPI SetSystemTime(
      __in  const SYSTEMTIME *lpSystemTime

    Sunday, April 15, 2012 8:08 AM


All replies

  • Hi,

    SetSystemTime API applies to "desktop app only". It cannot be used in Metro style app.

    You can get current system time by GetSystemTime API.

    Best wishes,

    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Yongwei Yao Monday, April 16, 2012 6:19 AM
    Monday, April 16, 2012 3:25 AM
  • Hi,

    I know SetSystemTime API cannot be used in metro style app ,but I want to know Is there  method

    to change system time by Javascript on metro style application.

    Monday, April 16, 2012 8:27 AM
  • I doubt there is. Why would a metro app want to change the system time? The system is usually updated by a NTP Server anyway
    Monday, April 16, 2012 1:18 PM
  • Another way, could Metro Style App trigger a system event to sync system time through NTP Server by JavaScript?

    Some network service will check the timestamp between server and client to verify the request is valid or not.

    If the date, time or timezone of system is not correct, request will be refused.

    Wednesday, April 18, 2012 9:27 AM
  • No

    Why would you or your customer want a Metro style app that changes the system time?  What is your use case?


    Jeff Sanders (MSFT)

    Wednesday, April 18, 2012 12:07 PM
  • Don't worry. This is taken care of by Windows 8. It updates the system time using NTP servers already. No need for Metro apps (or any Application for that matter) to interfere with that.
    Wednesday, April 18, 2012 1:05 PM
  • Hi,

    not quite the same question but related: Is there at least a way to change the time ZONE? We'd like to create a Metro app that makes switching the system time zone between a few zones easy.

    Does anyone know how to do that? In Win32 it would be in kernel32.dll.

    - Claus

    Thursday, May 10, 2012 8:50 PM
  • No, you cannot make system changes from a Metro style app

    Jeff Sanders (MSFT)

    Friday, May 11, 2012 12:16 PM