Need help with javascript date format

dave doyle
dave doyle used Ask the Experts™
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>
        <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;
<% newDate=jsGetPastTimeCurrent(-360)%>
    <h2><%= newDate %> </h2>
Watch Question

Do more with

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


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

Yes, it can convert the time zones as well.


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