如何从Windows Phone 7中的DateTime中减去秒?

ben*_*lim 9 c# windows-phone-7

我试图在时间选择器中减去时间值的秒.我发现代码在picker值中添加了第二个,但我无法弄清楚如何减去.

我应该怎么做呢?

private static void CreateAlarm(DateTime time, string title)
{
    var alarm = new Alarm(title)
    {
        Content = "You have a meeting with your team now.",
        BeginTime = time.AddSeconds(10),
    };
}

private void SetAlarm_Click(object sender, RoutedEventArgs e)
{
    CreateAlarm(Convert.ToDateTime(timePicker1.ValueString), textBox1.Text);
}
Run Code Online (Sandbox Code Playgroud)

Mik*_*iaz 17

只需添加一个减号:

EndTime = time.AddSeconds(-10)
Run Code Online (Sandbox Code Playgroud)