一个时间格式的函数,可以把时间格式为各种输出

转载 2006年06月01日 09:52:00

一个时间格式的函数,可以把时间格式为各种输出

<%
'一个时间格式的函数,可以把时间格式为各种输出
Function DateToStr(DateTime,ShowType)
 Dim DateMonth,DateDay,DateHour,DateMinute,DateWeek,DateSecond
 Dim FullWeekday,shortWeekday,Fullmonth,Shortmonth,TimeZone1,TimeZone2
 TimeZone1="+0800"
 TimeZone2="+08:00"
 FullWeekday=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
 shortWeekday=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
Fullmonth=Array("January","February","March","April","May","June","July","August","September","October","November","December")
Shortmonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

 DateMonth=Month(DateTime)
 DateDay=Day(DateTime)
 DateHour=Hour(DateTime)
 DateMinute=Minute(DateTime)
 DateWeek=weekday(DateTime)
 DateSecond=Second(DateTime)
 If Len(DateMonth)<2 Then DateMonth="0"&DateMonth
 If Len(DateDay)<2 Then DateDay="0"&DateDay
 If Len(DateMinute)<2 Then DateMinute="0"&DateMinute
 Select Case ShowType
 Case "Y-m-d"
  DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay
 Case "Y-m-d H:I A"
  Dim DateAMPM
  If DateHour>12 Then
   DateHour=DateHour-12
   DateAMPM="PM"
  Else
   DateHour=DateHour
   DateAMPM="AM"
  End If
  If Len(DateHour)<2 Then DateHour="0"&DateHour
  DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&" "&DateAMPM
 Case "Y-m-d H:I:S"
  If Len(DateHour)<2 Then DateHour="0"&DateHour
  If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
  DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond
 Case "YMDHIS"
  DateSecond=Second(DateTime)
  If Len(DateHour)<2 Then DateHour="0"&DateHour
  If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
  DateToStr=Year(DateTime)&DateMonth&DateDay&DateHour&DateMinute&DateSecond
 Case "YM"
  DateToStr=Right(Year(DateTime),2)&DateMonth
 Case "D"
  DateToStr=DateDay
Case "YMD"
DateToStr=Right(Year(DateTime),4)&DateMonth&DateDay
Case "MDY"
Dim DayEnd
select Case DateDay
Case 1
DayEnd="st"
Case 2
DayEnd="nd"
Case 3
DayEnd="rd"
Case Else
DayEnd="th"
End Select
DateToStr=Fullmonth(DateMonth-1)&" "&DateDay&DayEnd&" "&Right(Year(DateTime),4)
Case "w,d m y H:I:S"
  DateSecond=Second(DateTime)
  If Len(DateHour)<2 Then DateHour="0"&DateHour
  If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
DateToStr=shortWeekday(DateWeek-1)&","&DateDay&" "& Left(Fullmonth(DateMonth-1),3) &" "&Right(Year(DateTime),4)&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&TimeZone1
Case "y-m-dTH:I:S"
  If Len(DateHour)<2 Then DateHour="0"&DateHour
  If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
  DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&"T"&DateHour&":"&DateMinute&":"&DateSecond&TimeZone2
 Case Else
  If Len(DateHour)<2 Then DateHour="0"&DateHour
  DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute
 End Select
End Function

'调用方式,当用下面的字符串格式时,就显示该时间格式
'[Y-m-d][Y-m-d H:I A][Y-m-d H:I:S][YMDHIS][YM][d][YMD][MDY]
response.Write DateToStr(now(),"w,d m y H:I:S")
%>

C# 判断一个时间点是否位于给定的时间区间(字符串格式)

本文中实现了函数static bool isLegalTime(DateTime dt, string time_intervals);给定一个字符串表示的时间区间time_intervals:1)每...

一个时间函数

public static DateTime GetAnnDate(DateTime curDate, int freqencyType, int day, int month, int countT...

jquery 做的一个时间验证

  • 2010年07月30日 07:29
  • 451KB
  • 下载

使用Vue.js创建一个时间跟踪的单页应用

Vue.js很简单。正因为如此简单,人们常常认为其适合于小项目。虽然真正的Vue.js核心知识只是一个视图层库,实际上有一组工具,将使您能够使用Vue.js构建完整的大规模SPA(单页应用程序)。 ...

一个时间转换小功能

  • 2015年08月07日 14:38
  • 11KB
  • 下载

一个时间戳修改器^_^

  • 2009年07月02日 18:18
  • 401KB
  • 下载

Spring Quartz任务调度示例(指定一个时间触发调度任务)

 --1.创建一个类,类中方法doAuth(),对这个方法进行触发package com.xzl.quartz;import org.apache.log4j.Logger; public clas...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:一个时间格式的函数,可以把时间格式为各种输出
举报原因:
原因补充:

(最多只允许输入30个字)