c#比较两时间大小
1、比较时间大小的实验
string st1="12:13";
string st2="14:14";
datetime dt1=convert.todatetime(st1);
datetime dt2=convert.todatetime(st2);
datetime dt3=datetime.now;
if(datetime.compare(dt1,dt2)>0)
msg.text=st1+">"+st2;
else
msg.text=st1+"<"+st2;
msg.text+="rn"+dt1.tostring();
if(datetime.compare(dt1,dt3)>0)
msg.text+="rn"+st1+">"+dt3.tostring();
else
msg.text+="rn"+st1+"<"+dt3.tostring();
2、计算两个时间差值的函数,返回时间差的绝对值:
private string datediff(datetime datetime1,datetime datetime2)
{
string datediff=null;
try
{
timespan ts1=new timespan(datetime1.ticks);
timespan ts2=new timespan(datetime2.ticks);
timespan ts=ts1.subtract(ts2).duration();
datediff=ts.days.tostring()+"天" +ts.hours.tostring()+"小时" +ts.minutes.tostring()+"分钟" +ts.seconds.tostring()+"秒";
}
catch
{
}return datediff;
}
3、实现计算datetime1-36天=datetime2的功能
timespan ts=new timespan(40,0,0,0);
datetime dt2=datetime.now.subtract(ts);
msg.text=datetime.now.tostring()+"-"+ts.days.tostring()+"天rn"; msg.text+=dt2.tostring();
疯狂医院达什医生中文版(Crazy Hospital)
疯狂医院达什医生最新版是一款医院模拟经营类游戏,逼真的场景画
宝宝庄园官方版
宝宝庄园官方版是一款超级经典好玩的模拟经营类型的手游,这个游
桃源记官方正版
桃源记是一款休闲娱乐类的水墨手绘风格打造的模拟经营手游。玩家
长途巴士模拟器手机版
长途巴士模拟器汉化版是一款十分比真好玩的大巴车模拟驾驶运营类
房东模拟器最新版2024
房东模拟器中文版是一个超级有趣的模拟经营类型的手游,这个游戏