asp 时间日期格式化程序

'函数名:FormatTime
  '作  用:时间格式化
  '参  数:DateTime ----要格式化的时间
  '       Format   ----格式的形式
  '****************************************************
  Public Function FormatTime(DateTime,Format)
   select case Format
   case "1"
  FormatTime=""&year(DateTime)&"年"&month(DateTime)&"月"&day(DateTime)&"日"
   case "2"
  FormatTime=""&month(DateTime)&"月"&day(DateTime)&"日"
   case "3"
  FormatTime=""&year(DateTime)&"/"&month(DateTime)&"/"&day(DateTime)&""
   case "4"
  FormatTime=""&month(DateTime)&"/"&day(DateTime)&""
   case "5"
  FormatTime=""&month(DateTime)&"月"&day(DateTime)&"日"&FormatDateTime(DateTime,4)&""
   case "6"
   temp="周日,周一,周二,周三,周四,周五,周六"
   temp=split(temp,",")
   FormatTime=temp(Weekday(DateTime)-1)
   case Else
   FormatTime=DateTime
   end select
  End Function
 
 Public Function TimeToDiff(DateTime)
  If IsDate(DateTime) Then
   Dim tSecond:tSecond=DateDiff("s",DateTime,Now())
   If tSecond<60 Then'//一分钟内
    TimeToDiff="刚刚"
   End If
   If tSecond>=60 And tSecond<3600 Then'//一小时内
    TimeToDiff=DateDiff("n",DateTime,Now())&"分钟前"
   End If
   If tSecond>=3600 And tSecond<86400 Then'//一天内
    TimeToDiff=DateDiff("h",DateTime,Now())&"小时前"
   End If
   If tSecond>=86400 And tSecond<2592000 Then'//一个月内
    TimeToDiff=DateDiff("d",DateTime,Now())&"天前"
   End If
   If tSecond>=2592000 And tSecond<31536000 Then'//一年内
    TimeToDiff=DateDiff("m",DateTime,Now())&"个月前"
   End If
   If tSecond>=31536000 Then'//其它
    TimeToDiff=DateDiff("yyyy",DateTime,Now())&"年前"
   End If
  Else
   TimeToDiff="N天前"
  End If
 End Function

时间: 2024-09-02 15:59:44

asp 时间日期格式化程序的相关文章

js时间日期格式化封装函数_javascript技巧

js虽然提供了各种获取时间Date对象的不同属性方法,如:getDate 方法 | getDay 方法 | getFullYear 方法 | getHours 方法 ... ... 等等,但是却没有像java那样提供一个方法来供用户来根据自身提供的模板(pattern),来格式化指定时间对象,所以自己就封装了一个小方法,只供大家闲来调侃-.-,有好的建议还望慷慨指荐哦. 用到知识点: arguments:该对象代表正在执行的函数和调用它的函数的参数.不可显式创建,虽然有length属性,且能像数

ASP常用日期格式化函数 FormatDate()

核心代码 <% '功能:多功能日期格式化函数 '来源:http://jorkin.reallydo.com/article.asp?id=477 Function FormatDate(sDateTime, sReallyDo) Dim sJorkin sJorkin = GetLocale() If Not IsDate(sDateTime) Then sDateTime = Now() sDateTime = CDate(sDateTime) Select Case UCase(sReall

Asp中日期格式化问题

对于access数据库的日期时间类型字段存储的日期,直接从数据库中读出显示的效果是带时间的如,2009-06-13 18:00 ,如果只是希望显示日期应该怎么办呢? Vbscrip有一个函数FormatDateTime().其说明如下: 返回表达式,此表达式已被格式化为日期或时间.  FormatDateTime(Date[, NamedFormat]) 参数 Date 必选项.要被格式化的日期表达式. NamedFormat 可选项.指示所使用的日期/时间格式的数值,如果省略,则使用 vbGe

java计算时间日期间隔程序

计算时间差 **/  代码如下 复制代码     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");     String systemTime = sdf .format(new Date()).toString();     将截取到的时间字符串转化为时间格式的字符串 **/     Date begin=sdf.parse(2008-03-28 11:55:30);     Date end =

php中时间日期格式化函数

 代码如下 复制代码 function format_date( $STRING1 ) {         $STRING1 = str_replace( "-0", "-", $STRING1 );         $STR = strtok( $STRING1, "-" );         $STRING2 = $STR."年";         $STR = strtok( "-" );      

Asp 日期格式化问题_应用技巧

对于access数据库的日期时间类型字段存储的日期,直接从数据库中读出显示的效果是带时间的如,2009-06-13 18:00 ,如果只是希望显示日期应该怎么办呢? Vbscrip有一个函数FormatDateTime().其说明如下: 返回表达式,此表达式已被格式化为日期或时间. FormatDateTime(Date[, NamedFormat]) 参数 Date 必选项.要被格式化的日期表达式. NamedFormat 可选项.指示所使用的日期/时间格式的数值,如果省略,则使用 vbGen

Asp 日期格式化问题

对于access数据库的日期时间类型字段存储的日期,直接从数据库中读出显示的效果是带时间的如,2009-06-13 18:00 ,如果只是希望显示日期应该怎么办呢? Vbscrip有一个函数FormatDateTime().其说明如下: 返回表达式,此表达式已被格式化为日期或时间. FormatDateTime(Date[, NamedFormat]) 参数 Date 必选项.要被格式化的日期表达式. NamedFormat 可选项.指示所使用的日期/时间格式的数值,如果省略,则使用 vbGen

asp 格式化时间日期

asp教程 格式化时间日期 public function formatdt(dt, style) 'style=0 2000-10-10 下午 12:17:45 'style=1 2000-10-10 23:17:45 'style=2 2000-10-10 23:45 'style=3 00-10-10 23:45 'style=4 10-10 23:45 'style=5 2000-10-10 'style=6 00-10-10 'style=7 10-10 'style=8 23h-45

java时间日期格式化工具类程序

例1.整理了一份可重用的日期格式化工具类,在日常开发中悲催的程序员离不开这个工具类的 下面给大家把java日期工具类代码贡献上:  代码如下 复制代码 /**  * 日期工具类-www.111cn.net网整理  * 默认使用 "yyyy-MM-dd HH:mm:ss" 格式化日期  * @author xw素材网  */ public final class DateUtils { /** * 英文简写(默认)如:2010-12-01 */ public static String