我如何安排日期和时间 [英] How Do I Cancate Date And Time

查看:146
本文介绍了我如何安排日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想结束日期和时间。这是我的代码。

I wanted to concate date and time. Here is my code.

string dateOfCheckOut = lblDateData.InnerText;
DateTime dateofCheckOut = Convert.ToDateTime(dateOfCheckOut);
string date = dateofCheckOut.ToString("MM/dd/yyyy");

endTimeOfAttendance = configSetting.EndTimeOfAttendance.ToString("HH:mm:ss");

DateTime dateTimeOfCheckout = DateTime.Parse(dateOfCheckOut + " " + endTimeOfAttendance);





这里的数据来自 lblDateData ,时间将来自 endTimeOfAttendance 这是从表中存储的时间中提取的,这是2014-05-02 17:30:00.000 ..我希望日期为 lblDateData 但是时间是17:30:00.000。在这里,我联系,dateTimeOfCheckout将显示我想在localhost中的值,如果日期是2014-05-05,dateTimeOfCheckoutill是2014-05-05 17:30:00.000但是因为它在IIS中发布,dateTimeOfCheckout值将是2014- 05-05 00:00:00.000



是否有需要的东西..任何人都可以告诉如何纠正它?提前谢谢



here data will come from lblDateData and time will come from endTimeOfAttendance which is extracted from time stored in table which is 2014-05-02 17:30:00.000 .. i wanted date to be of lblDateData but time to be 17:30:00.000. here as i concate,dateTimeOfCheckout will show value as i wanted in localhost say if date is 2014-05-05, dateTimeOfCheckoutill be 2014-05-05 17:30:00.000 but as it is published in IIS the dateTimeOfCheckout value will be 2014-05-05 00:00:00.000

Is there something that is required.. can anyone tell how to correct it?? thanks in advance

推荐答案

怎么样

What about
DateTime dateTimeOfCheckout = new DateTime(dateofCheckOut.Year, dateofCheckOut.Month, dateofCheckOut.Day, configSetting.EndTimeOfAttendance.Hour, configSetting.EndTimeOfAttendance.Minute, configSetting.EndTimeOfAttendance.Second);


尝试这个......



string dateOfCheckOut = lblDateData.InnerText;



string dateandtime = dateOfCheckOut ++ endTimeOfAttendance;



DateTime dateTimeOfCheckout = DateTime.ParseExact(dateandtime,dd / MM / yyyy hh:mm: ss tt,CultureInfo.InvariantCulture);





根据你的方式改变格式
try this one......

string dateOfCheckOut = lblDateData.InnerText;

string dateandtime =dateOfCheckOut +" "+endTimeOfAttendance ;

DateTime dateTimeOfCheckout = DateTime.ParseExact (dateandtime ,"dd/MM/yyyy hh:mm:ss tt" ,CultureInfo.InvariantCulture );


change the format according to your way


这篇关于我如何安排日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆