You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
431 B
17 lines
431 B
<script lang="ts">
|
|
export let time: Date | string = new Date();
|
|
|
|
let timeStr = "";
|
|
|
|
function formatTime(time: Date): string {
|
|
const pad = (n:number) => n < 10 ? '0'+n : n.toString();
|
|
|
|
return `${time.getFullYear()}-${pad(time.getMonth()+1)}-${pad(time.getDate())} ${pad(time.getHours())}:${pad(time.getMinutes())}`
|
|
}
|
|
|
|
$: timeStr = formatTime(new Date(time));
|
|
</script>
|
|
|
|
<span>{timeStr}</span>
|
|
|
|
<style></style>
|