如何在asp经典中使用YYYY-MM-DD日期格式?

Jay*_*Jay 4 asp-classic

我正在编写一个小代码,我需要在其上添加明天的日期.格式应该是YYYY-MM-DD,我已经尝试过"DateAdd("d",1,d_now)并返回MM-DD-YYYY.如何将其格式化为YYYY-MM-DD?

Cas*_*jne 5

格式还不够....

'format a number with the correct amount of digits 
    eg: 9 becomes 09 but 11 stays 11'

Function formatNumber(value, digits) 
    if digits > len(value) then 
        formatNumber = String(digits-len(value),"0") & value 
    else 
        formatNumber = value 
    end if 
End Function 

'write the date "manually"'

 response.write Year(date) &  "-" & _
 formatNumber(Month(date),2) & _
 "-" & formatNumber(Day(date),2) 
Run Code Online (Sandbox Code Playgroud)


小智 3

看看这篇文章 - 它可能会帮助你......如何在经典 asp 中转换日期字符串