Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format date

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
0
0
US
Can anybody tell me how I can format the system date to:

2003-11-25 11:01:50
 
<html>
<head>
<script language=&quot;vbscript&quot;>
function FormatSysDate()
dim sDate

sDate=datepart(&quot;yyyy&quot;,date()) & &quot;-&quot; & datepart(&quot;m&quot;,date()) & &quot;-&quot; & datepart(&quot;d&quot;,date()) & &quot; &quot; & datepart(&quot;h&quot;,time()) & &quot;:&quot; & datepart(&quot;n&quot;,time()) & &quot;:&quot; & datepart(&quot;s&quot;,time())

msgbox sDate
end function
</script>
</head>
<body>

<button onclick=&quot;FormatSysDate()&quot;>format date</button>
</body>
</html>

MrGreed

&quot;did you just say Minkey?, yes that's what I said.&quot;
 
Try something like this:
Code:
strDateTime=DatePart(&quot;yyyy&quot;,Date) & &quot;-&quot; & _
Right(&quot;00&quot; & DatePart(&quot;m&quot;,Date),2) & &quot;-&quot; & _
Right(&quot;00&quot; & DatePart(&quot;d&quot;,Date),2) & &quot; &quot; & _
Right(&quot;00&quot; & DatePart(&quot;h&quot;,Time),2) & &quot;:&quot; & _
Right(&quot;00&quot; & DatePart(&quot;n&quot;,Time),2) & &quot;:&quot; & _
Right(&quot;00&quot; & DatePart(&quot;s&quot;,Time),2)
WScript.Echo &quot;System DateTime is : &quot; & strDateTime

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top