Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f7fbe9a

Browse files
committed
New: large integer in JavaScript representing time in milliseconds, you can convert it to a readable date and time format using the
1 parent cac5e1d commit f7fbe9a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎basic/integer_to_time.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Assume you have a big integer for time in milliseconds
2+
const bigIntTime = 1672531199000n; // JavaScript BigInt, for example
3+
4+
// Convert BigInt to regular number if it's safe (less than MAX_SAFE_INTEGER)
5+
const timeInMilliseconds = Number(bigIntTime);
6+
7+
// Create a Date object from the milliseconds
8+
const date = new Date(timeInMilliseconds);
9+
10+
// Format the date to a readable format
11+
const formattedDate = date.toISOString(); // "2023年01月01日T00:59:59.000Z"
12+
13+
console.log(formattedDate);
14+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /