Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert dd.mm.yyyy format to yyyy-mm-dd

Tags:

javascript

How can I convert dd.mm.yyyy format date to yyyy-mm-dd format in JavaScript?

Here is an example:

30.01.2010
to 
2010-01-30

Meaning convert d.m.Y to Y-m-d. I know how to do this in PHP but I need it in JavaScript.

like image 316
ant Avatar asked Feb 13 '10 16:02

ant


People also ask

How do I change the date format from dd mm yyyy to dd mm yyyy?

First, pick the cells that contain dates, then right-click and select Format Cells. Select Custom in the Number Tab, then type 'dd-mmm-yyyy' in the Type text box, then click okay. It will format the dates you specify.

How do you convert mm/dd/yyyy format?

If you want to change the format in excel ,Click 'Home' Tab in the Ribbon-> In 'number 'Group->Choose 'more number format'-> 'custom'->change the 'type' as "DD-MM-YYYY". If you want to change the format when export it from SQL Server Database to excel.

How do I change the date format from YYYY MM DD in Excel?

1. Select a blank cell next to your date, for instance. I1, and type this formula =TEXT(G1, "yyyy-mm-dd"), and press Enter key, then drag AutoFill handle over the cells needed this formula. Now all dates are converted to texts and shown as yyyy-mm-dd format.


1 Answers

You can do this pretty simply. Just split the european date into an array, reverse it, and then join it with dashes.

var euro_date = '30.01.2010';
euro_date = euro_date.split('.');
var us_date = euro_date.reverse().join('-');
like image 119
ashrewdmint Avatar answered Oct 26 '22 07:10

ashrewdmint