Discussion:
[AngularJS] How Do I Get The Date In The Format That I Want
ShatterStar
2015-12-23 08:00:40 UTC
Permalink
Hi Guys,

I am trying to get the date that I have as a hidden field to be the current
date which would include the year, month and day eg. 2015-12-25, this is
how I am doing it thus far but is there a better / easier way? Here's the
code

var newDate = new Date();
dateYear = newDate.getFullYear();
dateMonth = newDate.getMonth();
dateDay = newDate.getDate();
$scope.myDate = dateYear + " " + dateMonth + " " + dateDay;
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Robert Zehnder
2015-12-23 14:15:08 UTC
Permalink
Have you looked into the date filter? It sounds like it may do what you
need.

https://docs.angularjs.org/api/ng/filter/date
Post by ShatterStar
Hi Guys,
I am trying to get the date that I have as a hidden field to be the
current date which would include the year, month and day eg. 2015-12-25,
this is how I am doing it thus far but is there a better / easier way?
Here's the code
var newDate = new Date();
dateYear = newDate.getFullYear();
dateMonth = newDate.getMonth();
dateDay = newDate.getDate();
$scope.myDate = dateYear + " " + dateMonth + " " + dateDay;
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
ShatterStar
2015-12-24 09:56:46 UTC
Permalink
Hi Robert I did see that I thought there may be a better alternative I'll
just have to get used to the way that AngularJS does things - thanks
Post by Robert Zehnder
Have you looked into the date filter? It sounds like it may do what you
need.
https://docs.angularjs.org/api/ng/filter/date
Post by ShatterStar
Hi Guys,
I am trying to get the date that I have as a hidden field to be the
current date which would include the year, month and day eg. 2015-12-25,
this is how I am doing it thus far but is there a better / easier way?
Here's the code
var newDate = new Date();
dateYear = newDate.getFullYear();
dateMonth = newDate.getMonth();
dateDay = newDate.getDate();
$scope.myDate = dateYear + " " + dateMonth + " " + dateDay;
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Ankush Joshi
2015-12-29 07:13:41 UTC
Permalink
Hello,


<span ng-non-bindable>{{1288323623006 | date:'medium'}}</span>:
<span>{{1288323623006 | date:'medium'}}</span><br><span ng-non-bindable>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span>:
<span>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span><br><span ng-non-bindable>{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}</span>:
<span>{{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}</span><br><span ng-non-bindable>{{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}</span>:
<span>{{'1288323623006' | date:"MM/dd/yyyy 'at' h:mma"}}</span><br>
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Loading...