TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
xeo zer
NA
52
4.8k
how to convert military time to standard
Jun 23 2017 6:59 AM
DateTime ottimein, ottimeout;
DateTime pmtimein, pmtimeout;
DateTime amtimein, amtimeout;
DateTime extra;
amtimein = DateTime.Parse(txt1.Text + "AM");
amtimeout = DateTime.Parse(txt2.Text + "AM");
pmtimein = DateTime.Parse(txt3.Text + "PM");
pmtimeout = DateTime.Parse(txt4.Text + "PM");
ottimein = DateTime.Parse(txt5.Text + "PM");
ottimeout = DateTime.Parse(txt6.Text + "PM");
extra = DateTime.Parse(txtExtra.Text + "AM").AddHours(12);
TimeSpan ts = new TimeSpan(0);
var am = amtimein;
var amout = amtimeout;
TimeSpan diff = amout.Subtract(am);
var pmin = pmtimein;
var pmout = pmtimeout;
TimeSpan diffpm = pmtimeout.Subtract(pmtimein);
var otin = ottimein;
var otout = ottimeout;
TimeSpan diffot = ottimeout.Subtract(ottimein);
if (diff < ts)
{
var res = diff + TimeSpan.FromHours(12);
var res_s= diffpm;
var res_r=diffot;
var _s = res + res_s + res_r;
txtm.Text = res.ToString(@"hh\mm");
}
else
{
var res = diff;
var res_s = diffpm;
var res_r = diffot;
var _s = res + res_s + res_r;
txtm.Text = res.ToString(@"hh\mm");
}
Reply
Answers (
2
)
How to load java script using placeholder in MVC?
Unit Testing Sample source needed