Skip to content

TIME() returning a date in 1970 rather than current timestamp #2001

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

Closed
v-flashpoint opened this issue Feb 22, 2022 · 2 comments · Fixed by #2008
Closed

TIME() returning a date in 1970 rather than current timestamp #2001

v-flashpoint opened this issue Feb 22, 2022 · 2 comments · Fixed by #2008
Assignees
Labels

Comments

@v-flashpoint
Copy link

v-flashpoint commented Feb 22, 2022

According to the Redis docs, TIME() should show the current server time, as a timestamp since the Unix epoch, and the number of microseconds that have elapsed: https://redis.io/commands/TIME

However, doing client.time() returns a date in 1970, not the current time.

Sample code:

const redis = require('redis');
const client = redis.createClient();
client.connect();

 client.on('connect', function() {
    console.log('Connected!');
	client.TIME().then(function(reply){
		console.log(reply);
	});
});

Output: 1970-01-20T01:05:44.873Z { microseconds: 880958 }

Linux date +%s returns 1645544389, which is the current date/time

Environment:

  • Node.js Version: 14.19.0
  • Redis Server Version: 6.2.6
  • Node Redis Version: 4.0.4
  • Platform: Ubuntu 20.04.3 LTS
@simonprickett
Copy link
Contributor

Looking into this, code is here

export function transformReply(reply: [string, string]): TimeReply {

@simonprickett
Copy link
Contributor

It's missing a multiply by 1000 when creating the new date.

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

Successfully merging a pull request may close this issue.

2 participants