0

我需要按以下格式创建提取日期和时间。

extractDate='2011-10-18T12:00:00.000000'

最好的方法是什么,使用 vbscript / asp3 来做到这一点?我只是在考虑对 .000000 的结尾部分进行硬编码,因为这不是赛马哈哈

谢谢。

到目前为止,我从类似的东西开始;

xmlDateTime = FormatDateTime(Now(),0)
xmlDateTime = Replace(xmlDateTime, " PM", "")
xmlDateTime = Replace(xmlDateTime, " AM", "")
Response.Write xmlDateTime & "<br>"

更新:

我的潜在解决方案:

xmlDateTime = FormatDateTime(Now(),0)
xmlDateTime = Replace(xmlDateTime, " PM", "")
xmlDateTime = Replace(xmlDateTime, " AM", "")
Response.Write xmlDateTime & "<br>"
splitDateTime = Split(xmlDateTime, " ")

xmlDate = splitDateTime(0)
xmlTime = splitDateTime(1)

strYear = DatePart("yyyy",xmlDate)
strMonth = DatePart("m",xmlDate)
strDay = DatePart("d",xmlDate)


Response.Write strYear & "<br>"
Response.Write strMonth & "<br>"
Response.Write strDay & "<br>"

xmlDateTime = strYear & "-" & strMonth & "-" & strDay & "T" & xmlTime & ".000000"
Response.write xmlDateTime & "<br>"
4

1 回答 1

3

您需要手动构建日期字符串。

Function dd(str)
  dd = Right("0" & str, 2)
End Function

d = Now
extractDate = Year(d) & "-" & dd(Month(d)) & "-" & dd(Day(d)) & "T" _
  & dd(Hour(d)) & ":" & dd(Minute(d)) & ":" & dd(Second(d)) & ".000000"
于 2012-10-04T18:09:59.143 回答