1.0 TimeSpan 

 TimeSpan passTime = (TimeSpan)(DateTime.Now - curUser.refuseTime);
if (passTime.Days * 24 + passTime.Hours < 24)
{
string cs = string.Format("您撤单过后,24小时内不能接单,还要等{0}小时.", 24 - passTime.Hours);
return WriteError(cs);
}

  

2.0 timestamp 时间戳

        public static int ConvertDateTimeInt(System.DateTime time)
{
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
return (int)(time - startTime).TotalSeconds;
} public static int GetTimestamp()
{
return ConvertDateTimeInt(DateTime.Now);
}

3.0 缓存

if (HttpRuntime.Cache["access_token"] == null)
{
HttpRuntime.Cache.Insert("access_token", access_token, null, DateTime.Now.AddSeconds(expires_in - 60), System.Web.Caching.Cache.NoSlidingExpiration); //这里给数据加缓存,设置缓存时间
//"key"为缓存的键,access_token为缓存起来的值,null为缓存依赖项,这里没有使用缓存依赖项,所以为null,
//null后面为缓存的时间为7168秒 最后一个参数为设置时间的格式,ASP.NET允许你设置一个绝对过期时间或滑动过期时间,但不能同时使用,
//我们这里设置的为绝对过期时间,也就是刷新一次页面后缓存数据为7168秒,7168秒后会从数据库中重新获取。
}

  

最新文章

  1. JAVA Shallow heap &amp; Retained heap
  2. 使用BBED模拟Oracle数据库坏块
  3. Strip JS – 低侵入,响应式的 Lightbox 效果
  4. OpenSSL命令---pkcs7
  5. 统计图表--第三方开源--MPAndroidChart(一)
  6. springmvc环境的搭建
  7. Mysql数据库导出压缩并保存到指定位置备份脚本
  8. Spring-data-redis操作redis cluster
  9. C#读取word内容实践
  10. 洛谷P3975 弦论
  11. js判断手机邮箱格式(正则)
  12. Swing的特性
  13. CentOS7_JDK安装和环境变量配置
  14. 2016ICPC-大连 A Simple Math Problem (数学)
  15. [WPF]解决模板中ContextMenu绑定CommandParameter的问题
  16. ListView高效分页
  17. django 连接mysql 数据库
  18. 【安装Python环境】之安装Selenium2时报UnicodeDecodeError: &#39;utf-8&#39; codec can&#39;t decode byte 0xc8 in position 12: invalid continuation byte问题
  19. python:利用smtplib模块发送邮件详解
  20. 20135320赵瀚青LINUX第六周学习笔记

热门文章

  1. 《静静的dojo》 总体教程介绍
  2. git版本管理策略及相关技巧(A)
  3. windbg 基础命令实战 - 简单程序破解
  4. EF架构~数据分批批量提交
  5. MongoDB 简介
  6. SQL SERVER 2005/2008 中关于架构的理解(一)
  7. javascript_core_06之正则、Math、Date
  8. 如何优雅的使用vue+vux开发app -03
  9. 使用Connetion的属性RetainSameConnection
  10. 了解HTML表单之input元素的30个元素属性