dynamic date
This commit is contained in:
parent
47fb22b0b4
commit
e455a0cc0e
|
|
@ -2,7 +2,7 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
|
||||
// Helpers
|
||||
import { clockParser } from '../../helpers/clockParser';
|
||||
import { clockParser, dateParser } from '../../helpers/dates';
|
||||
|
||||
const ClockDate = () => {
|
||||
const [date, setDate] = useState<Date>(new Date());
|
||||
|
|
@ -12,7 +12,7 @@ const ClockDate = () => {
|
|||
return (
|
||||
<div id="time">
|
||||
<span className="time">{clockParser(date)}</span>
|
||||
<span className="date">14 февраля</span>
|
||||
<span className="date">{dateParser(date)}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,3 +6,10 @@ export const clockParser = (date: Date) => {
|
|||
})
|
||||
.split(' ')[1];
|
||||
};
|
||||
|
||||
export const dateParser = (date: Date) => {
|
||||
return date.toLocaleDateString('ru', {
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue