Skip to content

Instantly share code, notes, and snippets.

View myphpmaster's full-sized avatar

Mohd Sufian Othman myphpmaster

View GitHub Profile
@myphpmaster
myphpmaster / convert-UNIX-timestamp.js
Last active August 29, 2015 14:10 — forked from kmaida/convert-UNIX-timestamp.js
Convert UNIX timestamp to local time with timezone UTC+/- code
function convertTimestamp(timestamp) {
var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ('0' + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2), // Add leading 0.
ampm = 'AM',
time;