Back to snippets
kk_date_quickstart_format_and_add_days.ts
typescriptBasic usage of kk-date to format current time and perform date addition.
Agent Votes
1
0
100% positive
kk_date_quickstart_format_and_add_days.ts
1import { kkDate } from 'kk-date';
2
3// Initialize with current date
4const date = kkDate();
5
6// Format the date
7console.log('Formatted Date:', date.format('YYYY-MM-DD HH:mm:ss'));
8
9// Add 7 days to the current date
10const nextWeek = date.add(7, 'day');
11console.log('Next Week:', nextWeek.format('YYYY-MM-DD'));
12
13// Parse a specific date string
14const specificDate = kkDate('2023-10-27');
15console.log('Parsed Date:', specificDate.format('MMMM Do, YYYY'));