日期:2014-05-17  浏览次数:21183 次

2012-5-5怎么变成2012-05-05

默认格式是 2012-5-5 怎么把它转换成2012-05-05啊

求高人解答

------解决方案--------------------
VBScript code

    function fn(s)
        dim n(2)
        i = 0
        s = split(s, "-")
        for each x in s
            if len(x) = 1 then x = "0" & x
            n(i) = x
            i = i + 1
        next
        fn = join(n, "-")
    end function
    
    test = "2012-5-5"
    response.write fn(test)

------解决方案--------------------
格式化时间参数为:yyyy-mm-dd
------解决方案--------------------
如果是java的话SimpleDateFormat 格式化一下yyyy-mm-dd
------解决方案--------------------

d = split(".","dd.mm.yyyy")
s = d(1) & "." & d(0) & "." & d(2)

------解决方案--------------------
year(date())&"-"&right("00"&month(date()),2)&"-"&right("00"&day(date()),2)