I request the current date and time:

$ scope.currentDate = new Date ();

I "2017-10-04T12:24:42.572Z" : "2017-10-04T12:24:42.572Z" Then, on condition I want to display the 'Test' :

  <p ng-if="currentDate < dev.data_block">Test</p> 

Where dev.data_block - 2017-10-04 11:09:51 Accordingly, the condition does not work. How to bring these values ​​for comparison to one type?

  • so compare dates - Grundy
  • I need to compare the date / time. How to set the format of the Date () function to match -> 2017-10-04 11:09:51? - Valery Orlov
  • no way, Date returns a date object , not a string. But you can use pipe date from the angulyar, and you can transfer the necessary format to it - Grundy
  • <p ng-bind = "currentDate | date: 'yyyy-MM-dd HH: mm: ss'"> </ p> The format now seems similar, but the condition <p ng-if = "dev.data_block> currentDate | date: 'yyyy-MM-dd HH: mm: ss' "> 123 </ p> doesn’t work out ... - Valery Orlov
  • and why should he work if you never use a pipe in it? :) - Grundy

0