Skip to main content

Posts

Showing posts from September, 2015

JavaScript: How to Extract the Date from ISO 8601 Complete Date and Time Format (Plus Make It Readable)

The complete format looks like this: YYYY-MM-DDThh:mm:ss.sTZD Example: 1997-07-16T19:20:30.45+01:00 www.w3.org/TR/NOTE-datetime We want to extract everything before the letter "T" ("Time") there, the date pattern. And make the month as strings, e.g. March, May, July, and so forth. Plus, re-format the structure. This is in JavaScript . For other programming languages, there are built-in features to do it, perhaps. Like in Python, whoa dude. First, split the string Let's take the 1997-07-16T19:20:30.45+01:00 as an example input string. var input = "1997-07-16T19:20:30.45+01:00"; //string. input = input.split("T"); //array. //the "input" variable is now an array: ["1997-07-16", "19:20:30.45+01:00"] Second, get the first array element and split it again //the "input" is already an array from above method. //take only the first element. Redefine the "input". input = inpu...