10 examples of 'vue js format date' in JavaScript

Every line of 'vue js format date' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
249formatDate(date = new Date(), format = 'datetime') {
250 return dayjs(date).format(dateFormatPreset[format] || format);
251}
182getDateInstance( v ) {
183 return this.props.moment( v ).toDate();
184}
239formatDate(val:any):string {
240 return this.dateFormat.replace('yyyy', val.year)
241 .replace('mm', this.preZero(val.month))
242 .replace('dd', this.preZero(val.day));
243}
3export default function formatDate (date) {
4 return format(date, 'MM-dd');
5}
11format (fmt = 'yyyy-MM-dd HH:mm:ss') {
12 const obj = {
13 'y+': this.date.getFullYear(),
14 'M{2}': this._paddingZero(this.date.getMonth() + 1),
15 'd{2}': this._paddingZero(this.date.getDate()),
16 'H{2}': this._paddingZero(this.date.getHours()),
17 'h{2}': this._paddingZero(this.date.getHours() % 12),
18 'm{2}': this._paddingZero(this.date.getMinutes()),
19 's{2}': this._paddingZero(this.date.getSeconds()),
20 'M': this.date.getMonth() + 1,
21 'd': this.date.getDate(),
22 'H': this.date.getHours(),
23 'h': this.date.getHours() % 12,
24 'm': this.date.getMinutes(),
25 's': this.date.getSeconds(),
26 'W': this.date.getDay()
27 }
28 for (let [key, ] of Object.entries(obj)) {
29 const regexp = new RegExp(`(${key})([^a-zA-Z])?`)
30 if (regexp.test(fmt)) {
31 fmt = fmt.replace(RegExp.$1, obj[key])
32 }
33 }
34 return fmt
35}
50date(value) {
51 return formatDateTime(value, {});
52}
31getFormateDate(date) {
32 return moment(date).format('YYYYMMDD');
33}
10export function formatDate(date: Date): string {
11 return london(date).format('D MMMM YYYY');
12}
61function formatDate(value) {
62 if (value === null || value === undefined) return '';
63 if (Next && Next.moment) {
64 return Next.moment(value).format('YYYY-MM-DD');
65 }
66 return value;
67}
10export function format(t) {
11 return dayjs(t).format('YYYY-MM-DD HH:mm:ss')
12}

Related snippets