How to display estimated delivery date in German?

Solved

How to display estimated delivery date in German?

theithei
Excursionist
33 2 10

Hello, 
I want to display estimated delivery dates to my costumers in Shopify.

I found this great article and implemented their code as described.: https://www.identixweb.com/how-to-display-estimated-delivery-date-and-time-on-your-shopify-store/

The code is: 

<p> <img src="https://cdn-icons-png.flaticon.com/512/1670/1670915.png" style="height:25px;float:left;margin-right:10px;padding-bottom: 4px;"/>
Get it between <strong><span id="fromDate"></span> - <span id="toDate"></span></strong></p>
{{ '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js' | script_tag }}
<script>
var fromDate = Date.today().addDays(5);
if (fromDate.is().saturday() || fromDate.is().sunday()) {
fromDate = fromDate.next().monday();
}
var toDate = Date.today().addDays(10);
if (toDate.is().saturday() || toDate.is().sunday()) {
toDate = toDate.next().monday();
}
document.getElementById('fromDate').innerHTML = fromDate.toString('dddd MMMM dS');
document.getElementById('toDate').innerHTML = toDate.toString('dddd MMMM dS');
</script>

 
The problem with it: It displays the date in English. 
I can change the "Get it between" part, no problem.

But the dates and formatting is pulled from a database that is English as far as I know.

Does anyone have an idea how to change the database to a German one? 

Help would be greatly appreciated!

Kind regards
Thea

Accepted Solution (1)

theithei
Excursionist
33 2 10

This is an accepted solution.

Solved the problem myself,

for anyone interested:

<p> <img src="https://cdn-icons-png.flaticon.com/512/1670/1670915.png" style="height:25px;float:left;margin-right:10px;padding-bottom: 4px;"/>
Lieferung zwischen <strong><span id="fromDate"></span> und <span id="toDate"></span></strong> bei Bestellungen heute bis 14.00 Uhr </p>
{{ '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js' | script_tag }}
<script>
var fromDate = Date.today().addDays(1);
if (fromDate.is().saturday() || fromDate.is().sunday()) {
fromDate = fromDate.next().monday();
}
var toDate = Date.today().addDays(3);
if (toDate.is().sunday()) {
toDate = toDate.next().monday();
}
let options = { weekday: 'short', month: 'long', day: 'numeric' };
document.getElementById('fromDate').innerHTML = fromDate.toLocaleString('de-DE',options);
document.getElementById('toDate').innerHTML = toDate.toLocaleString('de-DE',options);
</script>

View solution in original post

Reply 1 (1)

theithei
Excursionist
33 2 10

This is an accepted solution.

Solved the problem myself,

for anyone interested:

<p> <img src="https://cdn-icons-png.flaticon.com/512/1670/1670915.png" style="height:25px;float:left;margin-right:10px;padding-bottom: 4px;"/>
Lieferung zwischen <strong><span id="fromDate"></span> und <span id="toDate"></span></strong> bei Bestellungen heute bis 14.00 Uhr </p>
{{ '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js' | script_tag }}
<script>
var fromDate = Date.today().addDays(1);
if (fromDate.is().saturday() || fromDate.is().sunday()) {
fromDate = fromDate.next().monday();
}
var toDate = Date.today().addDays(3);
if (toDate.is().sunday()) {
toDate = toDate.next().monday();
}
let options = { weekday: 'short', month: 'long', day: 'numeric' };
document.getElementById('fromDate').innerHTML = fromDate.toLocaleString('de-DE',options);
document.getElementById('toDate').innerHTML = toDate.toLocaleString('de-DE',options);
</script>