- Joined
- May 7, 2018
- Messages
- 4,547
In my most recent post here on the forum, I wrote about how you should clean and test your landing pages... otherwise, you might have some big problems that will most certainly affect your conversion rate.
In that post, I mentioned that a common landing page error is using the wrong date format for the GEO that you're advertising in. Using the wrong format for the date can make your page look less authentic, making you less money.
Typically affiliates write the date using Javascript with code that's as old as dinosaurs :
This code would output: June 26, 2020 (date of the day this post was written)
To make the date the right format you'd have to do research for every GEO you're advertising in, and then on top of that write some nasty code (like what's above) to format the date... for each landing page.
You can write the date the exact same way with a built-in Javascript function:
This code would output: June 26, 2020 (date of the day this post was written)
No giant language-specific array of months/days of the week, no thinking about how to format the date for your target GEO... just simple code that formats it how you need automatically.
If you change "en" to another language you'd get outputs like this:
If you're ultra lazy you can just make the whole thing dynamic, which will take the language you place in the URL as a URL parameter and use that:
BTW that code also adds the weekday to the output. So if you used a URL parameter on your landing page like lang=en your output would now look like this:
Friday, Jun 26, 2020
Happy Friday!
Now, you know a much better way to code the date for your landing pages. Welcome to the future my friends.
For your reference here are the MDN docs for toLocaleDateString.
P.S. I've made a codesandbox with a bunch of examples in it. I'd embed it here, but I don't think it's possible. Take a look if you want.
P.P.S. Before anyone asks... it's supported very well by the browsers. ~98%
In that post, I mentioned that a common landing page error is using the wrong date format for the GEO that you're advertising in. Using the wrong format for the date can make your page look less authentic, making you less money.
Typically affiliates write the date using Javascript with code that's as old as dinosaurs :
JavaScript:
var d = new Date();
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
document.getElementById("date").innerHTML = months[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
This code would output: June 26, 2020 (date of the day this post was written)
To make the date the right format you'd have to do research for every GEO you're advertising in, and then on top of that write some nasty code (like what's above) to format the date... for each landing page.
You can write the date the exact same way with a built-in Javascript function:
JavaScript:
document.getElementById("date").innerHTML = new Date().toLocaleDateString("en", {day: "numeric", month: "short", year: "numeric"});
This code would output: June 26, 2020 (date of the day this post was written)
No giant language-specific array of months/days of the week, no thinking about how to format the date for your target GEO... just simple code that formats it how you need automatically.
If you change "en" to another language you'd get outputs like this:
- German = 26. Juni 2020
- Spanish = 26 de junio de 2020
- Arabic = 26 ููููู 2020
If you're ultra lazy you can just make the whole thing dynamic, which will take the language you place in the URL as a URL parameter and use that:
JavaScript:
function getURLparams(n) {
return decodeURIComponent(
(RegExp(n + "=" + "(.+?)(&|$)").exec(location.search) || [null])[1] ||
""
);
}
document.getElementById(
"date"
).innerHTML = new Date().toLocaleDateString(getURLparams("lang"), {
day: "numeric",
month: "short",
year: "numeric",
weekday: "long"
});
BTW that code also adds the weekday to the output. So if you used a URL parameter on your landing page like lang=en your output would now look like this:
Friday, Jun 26, 2020
Happy Friday!
Now, you know a much better way to code the date for your landing pages. Welcome to the future my friends.
For your reference here are the MDN docs for toLocaleDateString.
P.S. I've made a codesandbox with a bunch of examples in it. I'd embed it here, but I don't think it's possible. Take a look if you want.
P.P.S. Before anyone asks... it's supported very well by the browsers. ~98%
Last edited: