-
-
Save jorlee92/c1b2b7080fe12d956b8b93e8c5d47dc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var server = net.createServer(listener); | |
server.listen(process.env.PORT); | |
console.log(process.env.PORT); | |
function listener(socket){ | |
var date = new Date(); | |
var minutes = date.getMinutes(); | |
var hour = date.getHours(); | |
var year = date.getFullYear(); | |
var month = date.getMonth() +1; | |
var day = date.getDate(); | |
if (month < 10){ | |
month = "0" + month.toString(); | |
} | |
if (day < 10){ | |
day = "0"+ day.toString(); | |
} | |
if (minutes < 10){ | |
minutes = "0" + minutes.toString(); | |
} | |
if (hour > 12){ | |
hour = hour - 12; | |
} | |
if (hour < 10){ | |
hour = "0" + hour; | |
} | |
var response = year + "-" + month + "-" + day + " " + hour + ":" + minutes; | |
console.log(response); | |
socket.end(response,"utf8"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment