I am struggling with some datetime formating in angularJS.
I would like to obtain the following date format 25/11/1990 14:35
based on a datetime string
containing 1990-11-25 14:35:00
without having to create a Date
object in the controller.
It seems like angular can only achieve proper datetime formatting if the input is a Date
object or if the String
does not contain hours or minutes
index.html
<div ng-app ng-controller=Ctrl>
String: {{'1990-11-25 14:35:00' | date:dd/MM/yyyy HH:mm}}<br>
string date: {{'1990-11-25' | date:dd/MM/yyyy}}<br>
Date: {{myDate | date:dd/MM/yyyy HH:mm}}
</div>
controller.js
function Ctrl($scope)
{
$scope.myDate = new Date(1990-11-25 14:35:00);
}
Output
string: 1990-11-25 14:35:00
string date: 25/11/1990
date: 25/11/1990 14:35
http://jsfiddle.net/CkBWL/612/
According to angular's documentation on the date filter,
the only format allowed for datetime string are:
datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ
Is there so a way to format a string containing 1990-11-25 14:35:00
into 25/11/1990 14:35
directly in the html without having to create a Date
object ?
Thanks for your help !