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>
  • 相关阅读:
    Stream流之三级查询
    SpringBoot日期格式的设置
    el表达式
    SpringMV+HuTool之验证码登录
    Spring注解详解
    @ResponseBody注解使用(返回字符串并不跳转)
    每日leetcode-数组-589. N 叉树的前序遍历
    python apply函数
    剑指offer-JZ6 旋转数组的最小数字
    torch.manual_seed()函数
  • 原文地址:https://www.cnblogs.com/chaowei119/p/215554.html
Copyright © 2011-2022 走看看