-2

I have this variable which has for example "12:12:12"

How can I format this into "12:12" only?

  • 2
    Possible duplicate of [Convert a Unix timestamp to time in JavaScript](https://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript) – guradio Jan 31 '18 at 03:47
  • Possible duplicate of [How to format a JavaScript date](https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date) – Herohtar Jan 31 '18 at 04:18

1 Answers1

1

If You have Date Object you can do :

Code:

dateFormat(new Date(), "mm/dd/yy, h:MM:ss TT");

Output

"05/30/14, 11:46:03 AM"

Notations :-

mm -> month
dd -> date
yy -> year
h  -> hour
MM -> minutes
ss -> seconds
TT -> AM/PM

Note :- If You dont want the current date time Pass the Date time object in place of new Date();

Hope this Helps you

Rohit shah
  • 825
  • 4
  • 15