Need help with javascript date format

dave doyle
dave doyle used Ask the Experts™
on
Need help getting this JavaScript to format with different date options like mm/dd/yyyy , mm/dd/yyyy 00:00 etc.

<%@ language="VBScript" %>
<!DOCTYPE html>
<html>
        <head>
        <script language='Javascript' runat='server'>

            function jsGetPastTimeCurrent(minutes) {
                var d = new Date();
                var past = new Date();
                past.setTime(d.getTime() + (minutes*60000));
                var utcString = past.toUTCString();
                var tz = utcString.indexOf("UTC");
                if (tz > 0) {
                    utcString = utcString.substring(0, tz) + "CT";
                }
                return utcString;
            }
        </script>
<% newDate=jsGetPastTimeCurrent(-360)%>
        <title>Timestamp</title>
    </head>
    <body>
    <p>
    <h2><%= newDate %> </h2>
    </p>
    </body>
</html>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
All-around developer
Commented:
To be honest, the preeminent JavaScript date handling library is Moment.js. I'd suggest using it:
https://momentjs.com/

Author

Commented:
I've seen that . My web server is UTC but I need central time . Do you think it would work?
Eddie ShipmanAll-around developer

Commented:
Yes, it can convert the time zones as well.

Author

Commented:
Thank you . I'll give it a try.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial