zoukankan
html css js c++ java
asp.net 处理和计算微博发布时间
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace MicroBlogForWP7.Classes { public class TimeParser { /// <summary> /// 把秒转换成分钟 /// </summary> /// <returns></returns> public static int SecondToMinute(int Second) { decimal mm = (decimal)((decimal)Second / (decimal)60); return Convert.ToInt32(Math.Ceiling(double.Parse(mm.ToString()))); } #region 返回某年某月最后一天 /// <summary> /// 返回某年某月最后一天 /// </summary> /// <param name="year">年份</param> /// <param name="month">月份</param> /// <returns>日</returns> public static int GetMonthLastDate(int year, int month) { DateTime lastDay = new DateTime(year, month, new System.Globalization.GregorianCalendar().GetDaysInMonth(year, month)); int Day = lastDay.Day; return Day; } #endregion #region 返回时间差 public static 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(); TimeSpan ts = DateTime2 - DateTime1; if (ts.Days >= 1) { dateDiff = DateTime1.Month.ToString() + "月" + DateTime1.Day.ToString() + "日"; } else { if (ts.Hours > 1) { dateDiff = ts.Hours.ToString() + "小时前"; } else { dateDiff = ts.Minutes.ToString() + "分钟前"; } } } catch { } return dateDiff; } #endregion #region 返回该微博是什么时候发的 /// <summary> /// 返回该微博是什么时候发的 /// </summary> /// <param name="year">发微博时间</param> /// <param name="month">当前时间</param> public static string GetWhenSendTime(DateTime BlogTime, DateTime NowTime) { DateTime t1 = BlogTime; DateTime t2 = NowTime; string RES = ""; if ((t2 - t1).TotalMinutes > 1440) { RES = t1.ToString("yyyy年MM月dd日 HH:mm"); } else if ((t2 - t1).TotalMinutes > 60) { RES = Math.Floor(((t2 - t1).TotalMinutes / 60)).ToString() + "小时" + (Math.Floor((t2 - t1).TotalMinutes) % 60).ToString() + "分钟前"; } else { if ((Math.Floor((t2 - t1).TotalMinutes) % 60) <= 0) RES = "刚刚更新"; else RES = (Math.Floor((t2 - t1).TotalMinutes) % 60).ToString() + "分钟前"; } return RES; } #endregion } }
查看全文
相关阅读:
jQuery 对象 等操作
根据文件大小自动判断单位B,KB,MB,GB
PHP 根据子ID递归获取父级ID,实现逐级分类导航效果
JQuery 目录树jsTree插件用法
关于循环列表中包含递归函数的问题
PHP文件上传大小限制问题
UEditor+七牛,实现图片直连上传
修改Ueditor的图片上传地址
Thinkphp3.2.3加载外部类并调用类里面的方法 获取token
七牛云--开发笔记
原文地址:https://www.cnblogs.com/javawebsoa/p/2458103.html
最新文章
总结com组件问题,随笔记录
怎么改自己手机的ip地址
HTTP代理使用方式
ip代理软件哪个比较好
爬虫代理解决ip限制
修改ip地址的方法
HTTP代理如何使用
国内ip切换软件哪个好
http代理的基本原理
换ip工具哪个好
热门文章
爬虫代理构建IP池
jquery for循环
使用bootstrap本机调试时,应该使用本地服务器地址访问,如http://192.168.19.112/rjshop/,否则360浏览器会出现不兼容的情况
微信公众号开发之发送模板消息
通过命令行操作MYSQL的方法 以及导入大的SQL备份文件
关于导入到阿里云虚机的数据库的中文为乱码的说明
Windows服务器上使用bat定时执行php
采集课件等文档
php替换字符串函数strtr()和str_repalce()区别
字符串操作函数 查找字符串在另一个字符串中最后一次出现的位置,并返回从该位置到字符串结尾的所有字符
Copyright © 2011-2022 走看看