Skip to content

Commit

Permalink
Add moment.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyuki12 committed Mar 22, 2023
1 parent 35fe7c8 commit a27e100
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -15,6 +15,7 @@
"@types/react-dom": "18.0.10",
"eslint": "8.33.0",
"eslint-config-next": "13.1.6",
"moment": "^2.29.4",
"next": "13.1.6",
"nostr-react": "^0.6.4",
"nostr-tools": "^1.2.1",
Expand Down
7 changes: 6 additions & 1 deletion src/pages/Nostr/test.tsx
Expand Up @@ -2,6 +2,7 @@ import { useRef } from "react";
import { useNostrEvents, dateToUnix, useProfile } from "nostr-react";
import PostButton from "@/components/PostButton";
import { nip19 } from "nostr-tools";
import moment from 'moment';

const Test = () => {
const now = useRef(new Date()); // Make sure current time isn't re-rendered
Expand All @@ -28,11 +29,15 @@ const Test = () => {

const renderImageList = (list) => {
const posts = events.map((event, index) => {
let dateTime = new Date(event.created_at * 1000);
let createdDate = dateTime.toLocaleDateString('ja-JP');
let createdTime = createdDate + ' ' + dateTime.toLocaleTimeString('ja-JP');

return (
<li className="item" key={index}>
<div className="card-container">
<div className="card-text">
{event.pubkey} {event.content} {event.created_at}
{event.pubkey} {event.content} {moment(createdTime).fromNow()}
</div>
</div>
</li>
Expand Down

0 comments on commit a27e100

Please sign in to comment.