You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
chore(examples): fix examples for v5 (#2938)
This commit is contained in:
committed by
GitHub
parent
bd5c230c62
commit
2c9ad2e772
@@ -6,7 +6,13 @@ const client = createClient();
|
||||
await client.connect();
|
||||
|
||||
const serverTime = await client.time();
|
||||
// 2022-02-25T12:57:40.000Z { microseconds: 351346 }
|
||||
// In v5, TIME returns [unixTimestamp: string, microseconds: string] instead of Date
|
||||
// Example: ['1708956789', '123456']
|
||||
console.log(serverTime);
|
||||
|
||||
client.destroy();
|
||||
// Convert to JavaScript Date if needed
|
||||
const [seconds, microseconds] = serverTime;
|
||||
const date = new Date(parseInt(seconds) * 1000 + parseInt(microseconds) / 1000);
|
||||
console.log('Converted to Date:', date);
|
||||
|
||||
client.close();
|
||||
|
Reference in New Issue
Block a user