Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chatMessage.timeSent in message.component.ts is not showing the current time #4

Open
dipali09 opened this issue Nov 12, 2017 · 3 comments

Comments

@dipali09
Copy link

I am having an error regarding timeStamp.In chat.service.ts U I am applying the code below.
this.chatMessages.push({
message:msg,
timeSent:this.timestamp,
email:email,
userName:"this.userName"
});
But it's not showing anything for the timeSent on the console and not in the firebase database. I am not having any idea how to debug it.

@ghost
Copy link

ghost commented Nov 27, 2017

what have you put in your:
getTimeStamp(){ }

in chat.services.ts?

@dipali09
Copy link
Author

` getTimeStamp(){

const now=new Date();
const date=now.getFullYear()+'/'+(now.getMonth()+1)+'/'+now.getDay();
const time=now.getHours()+'/'+now.getMinutes()+'/'+now.getSeconds();
return(now);

}`

@ghost
Copy link

ghost commented Nov 28, 2017

Change it to this, and it should work:

getTimeStamp(){
const now = new Date();
const date = now.getUTCFullYear() + '/' +
(now.getUTCMonth() + 1) + '/' +
now.getUTCDate();
const time = now.getUTCHours() + ':' +
now.getUTCMinutes() + ':' +
now.getUTCSeconds();

         return ( date + ' ' + time );

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant