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, 2022 in Web Development by gaurav
• 23,260 points
1,426 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, 2022 in Web Development by rajatha
• 7,680 points
1,351 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, 2022 in Web Development by rajatha
• 7,680 points
2,478 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, 2022 in Web Development by gaurav
• 23,260 points
1,060 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, 2022 in Web Development by gaurav
• 23,260 points
965 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, 2022 in Web Development by rajatha
• 7,680 points
555 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, 2022 in Web Development by rajatha
• 7,680 points
1,116 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,520 points
1,316 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,840 points
15,710 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,840 points
23,295 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,840 points
3,311 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP