How to manipulate date in HTML?

0

I'm thinking of a scheme, but I do not know how to do it and it's simple. I need to do the following calculation:

Day and Month x Month and Day, example, today's date:

Dia: 16
Mês: 07
x (vezes)
Mês: 07
Dia: 16

In a calculator it will look like this: 1607*716 = 1150612

Just do this, always make this calculation with the current date on the machine and display the value of the result.

Is there any way to do this in HTML?

    
asked by anonymous 16.07.2018 / 16:55

2 answers

1

Only HTML will not roll over from you manipulating data in this way.

What you can do is a very simple script:

<script>
  var atual = new Date();
  var dia = atual.getDate().toString();
  var mes = (atual.getMonth() + 1).toString();

  document.write(parseInt(dia+mes) * parseInt(mes+dia));
</script>

This should work.

I hope I have helped.

Hugs.

    
16.07.2018 / 17:13
1

With Javascript you can do as follows:

var date = new Date();
var day = '' + date.getDate();
var month = '' + (date.getMonth() + 1);

day = day.length == 1 ? '0' + day : day;
month = month.length == 1 ? '0' + month : month;

var result = parseInt(day + month) * parseInt(month + day);
    
16.07.2018 / 17:13