none
Xaml如何获得系统时间?如何计时? RRS feed

  • 问题

    1. 如何得到系统时间?
    2. 如何在某个事件触发以后开始计时,并在另一个事件触发时得到过去了的时间?
    2014年5月31日 8:30

答案

  • 你好,

    如何获取系统时间:

    	Windows::Globalization::Calendar^ c = ref new Windows::Globalization::Calendar;
    	c->SetToNow();
    	String^ hour = c->HourAsString();
    	String^ minute = c->MinuteAsString();
    

    如何使用计时器:用上面同样的办法,对比两个时间就可以了嘛~

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2014年6月2日 2:04
    版主

全部回复

  • 你好,

    如何获取系统时间:

    	Windows::Globalization::Calendar^ c = ref new Windows::Globalization::Calendar;
    	c->SetToNow();
    	String^ hour = c->HourAsString();
    	String^ minute = c->MinuteAsString();
    

    如何使用计时器:用上面同样的办法,对比两个时间就可以了嘛~

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2014年6月2日 2:04
    版主
  • Calendar类本身支持想减吗?还是需要自己写?(我指Calendar减Calendar,不是Calendar减几天或几年或几秒)
    2014年6月2日 3:17
  • 我刚刚看了下,貌似Calendar class 好像不行欸,要自己写。。

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2014年6月2日 5:43
    版主