检查日期时间变量的时间间隔 [英] check Time interval for datetime variable

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

问题描述

我正在asp.net中开发网站以进行在线预订.在我的网站中,我花费时间进行预订.假设如果有一个选择时间,则其他用户不能在该其他用户时间的30分钟之前或之前预订,这意味着如果我在3:30时预订,则其他用户不能预订该时间,如果他们想预订,则只能选择3:00或4:00时间.

I am developing website in asp.net for online booking.In my website i use time for booking. Suppose if any one select time then other user can not book after or before 30min of that other user time means if i book at 3:30 then other user can not book this time and if they want to book they only select 3:00 or 4:00 time.
Can any one help me to solve this.

推荐答案

D1,d2是2个datetime变量.假设这两个变量在下面的代码中保存了一些日期.

D1,d2 are 2 datetime variables. Assume those 2 variables hold some date in the below code.

DateTime d1 ;
DateTime d2 ;


int mindiff = (d2 - d1).Minutes;


//if its hours then

int mindiff = (d2 - d1).Hours;


这篇关于检查日期时间变量的时间间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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