zoukankan      html  css  js  c++  java
  • 几个asp+操作日期的函数

    一。各种时间加减的运算
    用时间间隔的方法减去一定的天数
    Function Date1()
    Dim NewTime as DateTime
    NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
    NewTime = NewTime.Format("MM/dd/yyyy", DateTimeFormatInfo)
    response.write(NewTime)
    End Function

    使用加负天数的方法减去一定的天数
    Public Function Date2()
    Dim NewTime as DateTime
    NewTime = DateTime.Now.AddDays(-7)
    Dim s as string = NewTime
    return s
    End Function

    返回日期名称字符串
    Function Date3()
    Dim NewTime as DateTime = now.addDays(-7)
    response.write(System.String.Format("{0:MM/dd/yyyy}",NewTime))
    End Function

    Function Date4()
    Dim NewTime as DateTime
    NewTime = now.addDays(-7)
    return NewTime.ToString()
    End Function


    使用长时间模式
    Public Function Date5()
    Dim NewTime as DateTime
    NewTime = Now()
    return newtime.toLongTimeString()
    End Function

    使用短时间模式
    Public Function Date6()
    Dim NewTime as DateTime
    NewTime = Now()
    return newtime.toShortTimeString()
    End Function

    使用长日期模式
    Public Function Date7()
    Dim NewTime as DateTime
    NewTime = Now()
    return newtime.toLongDateString()
    End Function

    使用短日起模式
    Public Function Date8()
    Dim NewTime as DateTime
    NewTime = Now()
    return newtime.toShortDatestring()
    End Function


    格式化日期函数

    格式化成通用格式
    Function Date9()
    Dim NewTime as DateTime
    NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
    return formatdatetime(NewTime, 0)
    End Function

    格式化成长日期格式
    Function Date10()
    Dim NewTime as DateTime
    NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
    return formatdatetime(NewTime, 1)
    End Function

    格式化成短日期格式
    Function Date11()
    Dim NewTime as DateTime
    NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
    return formatdatetime(NewTime, 2)
    End Function

    格式化成长时间格式
    Function Date12()
    Dim NewTime as DateTime
    NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
    return formatdatetime(NewTime, 3)
    End Function

    格式化成短时间格式
    Function Date13()
    Dim NewTime as DateTime
    NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
    return formatdatetime(NewTime, 4)
    End Function


    单独显示时间的年,月,日等部分

    显示日期
    Function Date14()
    Dim NewTime as DateTime = now.addDays(-7)
    dim s as string
    s = (System.String.Format("{0:dddd}",NewTime))
    Return s
    End Function

    返回日期的一周中的第几天
    Function Date15()
    Dim MyDate as DateTime
    Dim MyWeekDay as Integer
    MyDate = Now.AddDays(-5)
    MyWeekDay = Weekday(MyDate)
    return MyWeekDay
    End Function

    返回月份值
    Function Date16()
    Dim MyDate as DateTime
    Dim MyMonth as Integer
    MyDate = Now.AddDays(-5)
    MyMonth = Month(MyDate)
    return MyMonth
    End Function

    返回一个格式化后的字符串
    Function Date17()
    Dim MyDate as String
    MyDate = Format(Now(), "yyyy")
    return MyDate
    End Function
    </script>
  • 相关阅读:
    启用Netlogon debug,查看服务器验证瓶颈
    Windows Server 2016调整网卡顺序
    AD用户添加到组
    客户端查看/修改所属站点
    OpenCV相关库
    《塔木德》笔记
    《如何阅读一本书》笔记
    《创业维艰》笔记
    《社会心理学》笔记
    《智能商业》笔记
  • 原文地址:https://www.cnblogs.com/chaowei119/p/215554.html
Copyright © 2011-2022 走看看