Dani Vilardell | aae4e2d | 2020-09-22 17:33:39 +0200 | [diff] [blame] | 1 | |
| 2 | function getTimeAndDate() { |
| 3 | // Hora d'inici |
| 4 | hora_actual.setMinutes(0, 0, 0); // Arrodonir per baix els minuts |
| 5 | minuts = hora_actual.getMinutes() < 10 ? hora_actual.getMinutes().toString() + '0' : hora_actual.getMinutes().toString(); |
| 6 | document.getElementById("inici").innerHTML = hora_actual.getHours().toString() + ":" + minuts; |
| 7 | |
| 8 | // Hora de fi |
| 9 | hora_actual.setHours(hora_actual.getHours() + 1); // Sumar una hora |
| 10 | minuts = hora_actual.getMinutes() < 10 ? hora_actual.getMinutes().toString() + '0' : hora_actual.getMinutes().toString(); |
| 11 | document.getElementById("fi").innerHTML = hora_actual.getHours().toString() + ":" + minuts; |
| 12 | |
| 13 | // Data |
| 14 | dia = hora_actual.getDate(); |
| 15 | mes = hora_actual.getMonth() + 1; |
| 16 | any = hora_actual.getFullYear(); |
| 17 | data = dia.toString() + '/' + mes.toString() + '/' + any.toString(); |
| 18 | } |
Dani Vilardell | 238a547 | 2020-09-22 18:27:08 +0200 | [diff] [blame] | 19 | |
| 20 | function getDayFormat() { |
| 21 | dia = hora_actual.getDate(); |
| 22 | if(dia < 10) return "0" + dia; |
| 23 | else return "" +dia; |
| 24 | } |
| 25 | |
| 26 | function getMonthFormat() { |
| 27 | mes = hora_actual.getMonth() + 1; |
| 28 | if(mes < 10) return "0" + mes; |
| 29 | else return "" + mes; |
| 30 | } |
| 31 | |
| 32 | function getYearFormat() { |
| 33 | any = hora_actual.getFullYear(); |
| 34 | return "" +any; |
| 35 | } |