fix: timestamp in wrong timezone after save
This commit is contained in:
parent
290992dfce
commit
403a9634d2
14
index.html
14
index.html
@ -230,6 +230,15 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function formatDateToLocalInput(date) {
|
||||
const pad = (n) => n.toString().padStart(2, '0');
|
||||
const year = date.getFullYear();
|
||||
const month = pad(date.getMonth() + 1);
|
||||
const day = pad(date.getDate());
|
||||
const hours = pad(date.getHours());
|
||||
const minutes = pad(date.getMinutes());
|
||||
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
||||
}
|
||||
const STORAGE_KEY = 'milkProductionEntries';
|
||||
const REMOVED_KEY = 'milkProductionRemoved';
|
||||
|
||||
@ -238,7 +247,7 @@
|
||||
|
||||
const listEl = document.getElementById('list');
|
||||
const timestampInput = document.getElementById('timestamp');
|
||||
timestampInput.value = new Date().toISOString().slice(0, 16);
|
||||
timestampInput.value = formatDateToLocalInput(new Date());
|
||||
const amountInput = document.getElementById('amount');
|
||||
const submitBtn = document.getElementById('submit-btn');
|
||||
|
||||
@ -404,7 +413,8 @@
|
||||
entries.push(newEntry);
|
||||
save();
|
||||
render();
|
||||
timestampInput.value = new Date().toISOString().slice(0, 16);
|
||||
|
||||
timestampInput.value = formatDateToLocalInput(new Date());
|
||||
amountInput.value = '';
|
||||
updateSubmitState();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user