how to get only the day of the current date in angularjs

1

How could I get the day of my current date, so I get my current date:

$scope.CurrentDate = new Date();

But the day how do I get it?

    
asked by Ziul̺̿i̺̿n̺̿g̺̿ Maca̶yo 22.06.2017 в 19:49
source

2 answers

2

Use the% %%% JavaScript function.

var dateDay = new Date().getDay();
    
answered by 22.06.2017 в 19:58
0

One way would be through pure javascript:

To return, for example, the name from the number:

function getDia(index){
    var dia = new Array(7);
    dia[0] = "Domingo";
    dia[1] = "Lunes";
    dia[2] = "Martes";
    dia[3] = "Miércoles";
    dia[4] = "Jueves";
    dia[5] = "Viernes";
    dia[6] = "Sábado";
  return dia[index];

}

To use it

var d = new Date(); // Por ejemplo 1
var n = getDia(d.getDay());

The result:

Monday

And to get the number of the day the getDate () method is used.

d.getDate() // Por ej: 22

Example: link

I hope that is what you are looking for, but, do not hesitate to ask again. Greetings

    
answered by 22.06.2017 в 19:57