explorer: Display block timestamp (#20309)

This commit is contained in:
Justin Starry 2021-09-29 11:15:45 -04:00 committed by GitHub
parent 062d8e6c5a
commit 32ece63338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import { NavLink } from "react-router-dom";
import { clusterPath } from "utils/url";
import { BlockProgramsCard } from "./BlockProgramsCard";
import { BlockAccountsCard } from "./BlockAccountsCard";
import { displayTimestamp, displayTimestampUtc } from "utils/date";
export function BlockOverviewCard({
slot,
@ -65,6 +66,26 @@ export function BlockOverviewCard({
<span>{block.blockhash}</span>
</td>
</tr>
{block.blockTime && (
<>
<tr>
<td>Timestamp (Local)</td>
<td className="text-lg-right">
<span className="text-monospace">
{displayTimestamp(block.blockTime * 1000, true)}
</span>
</td>
</tr>
<tr>
<td>Timestamp (UTC)</td>
<td className="text-lg-right">
<span className="text-monospace">
{displayTimestampUtc(block.blockTime * 1000, true)}
</span>
</td>
</tr>
</>
)}
<tr>
<td className="w-100">Parent Slot</td>
<td className="text-lg-right text-monospace">

View File

@ -25,7 +25,7 @@ export function displayTimestampUtc(
const expireDate = new Date(unixTimestamp);
const dateString = new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "long",
month: "short",
day: "numeric",
timeZone: "UTC",
}).format(expireDate);