Skip to content
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

add datetime. #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@

DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"

#TZ=Asia/Tokyo
TZ=Asia/Rangoon
#TZ=UTC

# generated command: $ openssl rand -base64 32
NEXTAUTH_SECRET=akaCCoY3Gc2jTsid7Ofsl2nxbIdkzoGk3HEW/QM0PV0=
8 changes: 8 additions & 0 deletions app/_components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ export const mainMenu = (
<ListItemText primary='LeaderLine' />
</ListItemButton>
</Link>
<Link href='/datetime' passHref>
<ListItemButton>
<ListItemIcon>
<LineAxisIcon />
</ListItemIcon>
<ListItemText primary='datetime' />
</ListItemButton>
</Link>
</React.Fragment>
);

Expand Down
15 changes: 15 additions & 0 deletions app/datetime/_components/ClientComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use client';

import dayjs from 'dayjs';

export default function ClientComponent() {
const date = new Date();
const dayjsDate = dayjs();

return (
<>
<p>Client Component(Date): {date.toLocaleString()}</p>
<p>Client Component(Dayjs): {dayjs().toDate().toLocaleString()}</p>
</>
);
}
24 changes: 24 additions & 0 deletions app/datetime/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import styles from '../page.module.css';

import dayjs from 'dayjs';
import 'dayjs/locale/my';

import ClientComponent from '@/app/datetime/_components/ClientComponent';

export default function DateTimePage() {
const date = new Date();

return (
<main className={styles.main}>
<div className={styles.description}>
<div>
<p>Server Component(Date): {date.toLocaleString()}</p>
<p>Server Component(Dayjs): {dayjs().toDate().toLocaleString()}</p>
</div>
<div>
<ClientComponent />
</div>
</div>
</main>
);
}