Skip to content

Commit

Permalink
added date & time
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohit5Upadhyay committed Aug 18, 2024
1 parent 1631434 commit 9ef0584
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions public/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ const socket = io();
if(navigator.geolocation){
navigator.geolocation.watchPosition((position)=>{
const {latitude,longitude }= position.coords;
socket.emit("send-location",{latitude,longitude})
console.log("Sending location:", latitude, longitude);
const now = new Date();
const currentDate = now.toDateString();
const currentTime = now.toTimeString();
socket.emit("send-location",{
latitude,
longitude,
date: currentDate,
time: currentTime
})
console.log("Sending location:", latitude, longitude ,"Date:", currentDate, "Time:", currentTime);
},(error)=>{
console.log(error);
},{
Expand Down

0 comments on commit 9ef0584

Please sign in to comment.