Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
Advertisements
