All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
Asp.net,时间操作基类(短日期,长日期,时间差)_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/24 9:03:06 Browse times: 271 Comment times: 0

Asp.net,时间操作基类(短日期,长日期,时间差)_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

Asp.net 时间操作基类(短日期,长日期,时间差)_[Asp.Net教程]

/############################################
版权声明:
文章内容为本站编辑,创作.你可以任意转载、发布、使用但请务必以明文标注文章原始出处及本声明
http://www.opent.cn 作者:浪淘沙
############################################/

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace EC
{
///


/// 时间操作函数
///

public class TimeObject
{
///
/// 时间差
///

/// 开始时间
/// 结束时间
///
public static string GetTimeSpan(DateTime starttime, DateTime endtime)
{
TimeSpan ts = endtime - starttime;
return string.Format("{0}时{1}分{2}秒{3}毫秒", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
}

///
/// 转称为月-日:09-12
///

/// 日期
///
public static string ToDateMonthDay(DateTime d)
{
return d.ToString("MM-dd");
}
///
/// 转换为年月日:2006-09-12
///

///
///
public static string ToDateString(DateTime d)
{
return d.ToString("yyyy-MM-dd");
}
///
/// 转换为:小时:分:秒 00:29:58
///

///
///
public static string ToTimeString(DateTime t)
{
return t.ToString("HH:mm:ss");
}
///
/// 转换为长时间:2006-09-12 00:30:57
///

///
///
public static string ToDateTimeString(DateTime dt)
{
return dt.ToString("yyyy-MM-dd HH:mm:ss");
}


}

}

Asp.net 时间操作基类(短日期,长日期,时间差)

Asp.Net教程:/HtmlData/Program/Asp.Net/





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.