javascript date format Code Answer's

JavaScript is used to format dates in a variety of ways. It uses the date() function to create a date object that can be formatted using the new Date() function. The following example shows how to format a date. dd-mm-yyyy is a format for representing dates in JavaScript. It's a simple, readable format that's easy to parse and write.

php format date

By Xenophobic XenomorphXenophobic Xenomorph on Apr 14, 2020
<?php
  // To change the format of an existing date
  $old_date_format = "20/03/1999";
  $new_data_format = date("Y-m-d H:i:s", strtotime($old_date_format));

Add Comment

5

python date format

By Bewildered BeetleBewildered Beetle on Apr 22, 2020
%a - Abbreviated weekday name. (Sun, Mon, ...)
%A - Full weekday name. (Sunday, Monday, ...)
%w - Weekday as a decimal number. (0, 1, ..., 6)
%d - Day of the month as a zero-padded decimal. (01, 02, ..., 31)
%-d - Day of the month as a decimal number. (1, 2, ..., 30)
%b - Abbreviated month name. (Jan, Feb, ..., Dec)
%B - Full month name. (January, February, ...)
%m - Month as a zero-padded decimal number. (01, 02, ..., 12)
%-m - Month as a decimal number. (1, 2, ..., 12)
%y - Year without century as a zero-padded decimal number. (00, 01, ..., 99)
%-y - Year without century as a decimal number. (0, 1, ..., 99)
%Y - Year with century as a decimal number. (2013, 2019 etc.)
%H - Hour (24-hour clock) as a zero-padded decimal number. (00, 01, ..., 23)
%-H - Hour (24-hour clock) as a decimal number. (0, 1, ..., 23)
%I - Hour (12-hour clock) as a zero-padded decimal number. (01, 02, ..., 12)
%-I - Hour (12-hour clock) as a decimal number. (1, 2, ... 12)
%p - Locale’s AM or PM. (AM, PM)
%M - Minute as a zero-padded decimal number. (00, 01, ..., 59)
%-M - Minute as a decimal number. (0, 1, ..., 59)
%S - Second as a zero-padded decimal number. (00, 01, ..., 59)
%-S - Second as a decimal number. (0, 1, ..., 59)
%f - Microsecond as a decimal number, zero-padded on the left.  (000000 - 999999)
%z - UTC offset in the form +HHMM or -HHMM.  
%Z - Time zone name. 
%j - Day of the year as a zero-padded decimal number. (001, 002, ..., 366)
%-j - Day of the year as a decimal number. (1, 2, ..., 366)
%U - Week number of the year (Sunday as the first day of the week). All days in a new year preceding the first Sunday are considered to be in week 0. (00, 01, ..., 53)
%W - Week number of the year (Monday as the first day of the week). All days in a new year preceding the first Monday are considered to be in week 0. (00, 01, ..., 53)
%c - Locale’s appropriate date and time representation. (Mon Sep 30 07:06:05 2013)
%x - Locale’s appropriate date representation. (09/30/13)
%X - Locale’s appropriate time representation. (07:06:05)
%% - A literal '%' character. (%)

Add Comment

63

format date js

By NemesisNemesis on Nov 02, 2020
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

console.log(today.toLocaleDateString("en-US")); // 9/17/2016
console.log(today.toLocaleDateString("en-US", options)); // Saturday, September 17, 2016

 // For custom format use
 date.toLocaleDateString("en-US", { day: 'numeric' })+ "-"+ date.toLocaleDateString("en-US", { month: 'short' })+ "-" + date.toLocaleDateString("en-US", { year: 'numeric' }) // 16-Nov-2019

Source: stackoverflow.com

Add Comment

9

javascript date format

By Clever CraneClever Crane on Jun 05, 2020
const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

const options = {  year: 'numeric', month: 'short', day: 'numeric' };

console.log(event.toLocaleDateString('de-DE', options));
// expected output: Donnerstag, 20. Dezember 2012

console.log(event.toLocaleDateString('en-US', options));
// US format 


// In case you only want the month
console.log(event.toLocaleDateString(undefined, { month: 'short'}));
console.log(event.toLocaleDateString(undefined, { month: 'long'}));

Add Comment

12

javascript date format

By Panicky PandaPanicky Panda on May 31, 2020
const d = new Date('2010-08-05')
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d)
const mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d)
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d)

console.log(`${da}-${mo}-${ye}`)

Source: stackoverflow.com

Add Comment

1

javascript date format

By Monkey MonkMonkey Monk on Dec 18, 2020
Modern JavaScript date utility library https://date-fns.org/
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.

Add Comment

1

The above code examples show the javascript date format Code Answer's.

PHP answers related to "javascript date format"

View All PHP queries

PHP queries related to "javascript date format"

Browse Other Code Languages

CodeProZone