
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to convert a Unix timestamp to time in JavaScript?
To convert a Unix timestamp to time, you can try to run the following code in JavaScript −
Example
<html> <head> <title>JavaScript Dates</title> </head> <body> <script> var unix_time = 1514791901 ; var date = new Date(unix_time*1000); // get hours var hrs = date.getHours(); // get minutes var min = "0" + date.getMinutes(); // get seconds var sec = "0" + date.getSeconds(); document.write("Time- "+hrs + ":" + min.substr(-2) + ":" + sec.substr(-2)); </script> </body> </html>
Output
Time- 13:01:41
- Related Articles
- Convert MySQL timestamp to UNIX Timestamp?
- How to convert from Unix timestamp to MySQL timestamp value?
- How to convert Python date to Unix timestamp?
- How to convert MySQL datetime to Unix timestamp?
- How to convert unix timestamp string to readable date in Python?
- Convert MM/DD/YY to Unix timestamp in MySQL?
- Convert MySQL Unix-Timestamp format to date format?
- MySQL - Convert YYYY-MM-DD to UNIX timestamp
- Convert dd/mm/yyyy string to Unix timestamp in MySQL?
- How to convert a datetime string to millisecond UNIX time stamp?
- How to get the Unix timestamp in C#
- Convert UNIX timestamp into human readable format in MySQL?
- Python Pandas - Convert Timestamp to another time zone
- PHP program to convert a given timestamp into time ago
- How to get time in milliseconds since the Unix epoch in JavaScript?

Advertisements