• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6619
  • Last Modified:

Convert time to 24 hour format using VBScript

I am having trouble converting this VBScript to output 24 hour time. Can anyone provide a solution for me on what code changes need to take place to make this work?



Thanks,
Dave
Dim strDateTime : strDateTime = DateAdd("n", 1, Now())
Dim strDate     : strDate = LEFT(strDateTime, InStr(strDateTime, " ")-1)
Dim strTime     : strTime = MID(strDateTime, InStr(strDateTime, " ")+1)

wscript.echo strDatetime

Open in new window

0
hpops
Asked:
hpops
  • 2
  • 2
1 Solution
 
jorgedeoliveiraborgesCommented:
msgbox FormatDateTime (Now)
msgbox FormatDateTime (Now, 0)
msgbox FormatDateTime (Now, 1)
msgbox FormatDateTime (Now, 2)
msgbox FormatDateTime (Now, 3)
msgbox FormatDateTime (Now, 4)

Open in new window

0
 
RobSampsonCommented:
Try this.

Regards,

Rob.
Dim strDateTime, strDate, strTime
strDateTime = DateAdd("n", 1, Now())
strDate = Left(strDateTime, InStr(strDateTime, " ")-1)
strTime = FormatDateTime(strDateTime, 4)

strDateTime = strDate & " " & strTime

WScript.Echo strDatetime 

Open in new window

0
 
hpopsAuthor Commented:
Thanks Rob,

This code works perfectly in my script. If I could reward you more points, I would.

Dave
0
 
RobSampsonCommented:
No problem. Thanks for the grade.

Rob.
0
 
jorgedeoliveiraborgesCommented:
WScript.Echo FormatDateTime (Now, 0)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now