You can use either the built-in Date object in JavaScript or a library like moment.js to format a date in TypeScript. Here are examples using both methods:
Using the built-in Date object:
index.ts337 chars5 lines
Using moment.js:
index.ts210 chars7 lines
In the examples above, the date is first parsed from a string in ISO 8601 format ('YYYY-MM-DDThh:mm:ss') and then formatted using different methods. The format string for moment.js is similar to the one used by the strftime()
function in C.
gistlibby LogSnag