我希望24小时格式的时间 [英] I want to the time in 24 hour format
问题描述
我在gridview上有一个gridview我有一个时间计算的事情是,当我的第一列有一个时间17:00,当我选择17:00它会告诉我34:00但我想要时间正在向我展示10:00我怎样才能实现这个PLZ的帮助
我尝试了什么:
var result = TimeSpan.Parse(ScheduleArrival.Text)+ TimeSpan.Parse(LATE.SelectedValue +:+ LATE2.SelectedValue +:00);
EAT.Text = result.ToString();
I have a gridview on gridview i have a time calculation the thing is that when my first column is having a time 17:00 and when i select the 17:00 it will show me the 34:00 but i want the time is showing me the 10:00 how can i achieve this plz help
What I have tried:
var result = TimeSpan.Parse(ScheduleArrival.Text) + TimeSpan.Parse(LATE.SelectedValue + ":" + LATE2.SelectedValue + ":00");
EAT.Text = result.ToString();
推荐答案
解析对我来说有点奇怪,而且我使用了DateTime解析你想在这里注册一个pesific时间,而不是时间间隔:
var ts = DateTime.ParseExact(LATE.SelectedValue,HHmm,CultureInfo.InvariantCulture).TimeOfDay;
Parsing looks a bit strange to me, and Id use DateTime parse instead since you want a pesific time registered here, and not a time gap:
var ts = DateTime.ParseExact(LATE.SelectedValue", "HHmm", CultureInfo.InvariantCulture).TimeOfDay;
尝试:
Try:
EAT.Text = string.Format("{0}:{1}", result.Hours, result.Minutes);
这篇关于我希望24小时格式的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!