• Courses
  • Code Compiler
  • Discuss
  • Pricing
  • Teams
Menu
0

JavaScript Working with dates - how to change military time to normal timing (12hrs)

In JavaScript, when you get newDate(), it gets the military time (24hrs). How do you change it to normal timing (12 hrs)? https://code.sololearn.com/WljuSoBuCIW3/?ref=app

htmljavascriptchangewebbody24documenttiming12hrsgetdate()
10th Jun 2019, 11:13 PM
Ginfio
Ginfio - avatar
1 Answer
+ 1
date.toLocaleString('en-US') https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString https://code.sololearn.com/WuK38VeGfruw/?ref=app
11th Jun 2019, 12:52 AM
Gordon
Gordon - avatar

Often have questions like this?

Learn more efficiently, for free:

  • Introduction to Python

    7.1M learners

  • Introduction to Java

    4.7M learners

  • Introduction to C

    1.5M learners

  • Introduction to HTML

    7.5M learners

See all courses
Hot today
Anyone Have group of learning code?
1 Votes
Theres a lot of weird bugs in the Introduction to C++ course
2 Votes
The question is, Can AI replace programmers?
2 Votes
Bug in sololearn ?
0 Votes
Hi I want to learn react.js and I don't have even idea of coding just newbie
0 Votes
Why does range(5) print 0-4 in python
0 Votes
How do I complete this code to make “game over” appear on the screen.
0 Votes
Wouldn’t a erlang course be amazing?
1 Votes
Quiz module
0 Votes
Sorry for the interruption but i wants to build a os
0 Votes