How to convert UTC to CST using Javascript or Jquery

0 votes

I would like to convert the below time to CST. How can I achieve it using Jquery or Javascript? It should always display as a CST timezone.

var date = new Date();
    var dd = date.getDate();
    var mm = date.getMonth() + 1;
    var yy = date.getFullYear();
    var hh = date.getHours();
    var minutes = date.getMinutes();
    if (minutes < 10)
        minutes = "0" + minutes;

    var suffix = "AM";
    if (hh >= 12) {
        suffix = "PM";
        hh = hh - 12;
    }
    if (hh == 0) {
        hh = 12;
    }
    if (dd < 10) {
        dd = '0' + dd;
    }

    if (mm < 10) {
        mm = '0' + mm;
    }
    var valsss = (mm) + "/" + dd + "/" + yy + hh + " " + ":" + minutes + " " + suffix;
    $("#printDate").text(valsss);
<p id= "#printDate"></p>

Aug 11 in Web Development by gaurav
• 18,960 points
56 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Web Development

0 votes
1 answer

How to create a simple map using JavaScript/JQuery

var map = new Object(); // or ...READ MORE

answered Jun 27 in Web Development by rajatha
• 7,440 points
48 views
0 votes
0 answers

How to filter JSON Data in JavaScript or jQuery?

How to filter JSON data using Javascript ...READ MORE

Jul 1 in Web Development by rajatha
• 7,440 points
200 views
0 votes
0 answers

how to convert a decimal number to fraction using jquery

I want to convert the decimal number ...READ MORE

Jul 28 in Web Development by gaurav
• 18,960 points
33 views
0 votes
0 answers

How to disabled or non-editable text editor using CSS or jQuery?

I am using a rich text editor on my ...READ MORE

Aug 18 in Web Development by gaurav
• 18,960 points
19 views
0 votes
1 answer

How to place images using jQuery masonry plugin to start

You were just missing a css class that adjusts ...READ MORE

answered Jun 22 in Web Development by rajatha
• 7,440 points
26 views
0 votes
1 answer

How to alert using jQuery

alert($('#test')); // or alert($('#test'). get(0)); // also try alert(document. ...READ MORE

answered Jun 27 in Web Development by rajatha
• 7,440 points
29 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
322 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
9,280 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
16,451 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,780 points
1,413 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP