My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Month in JavaScript works in simple SVG, but not in complicated SVG

Gustavo Benedito Costa's photo
Gustavo Benedito Costa
·Dec 22, 2018

Hello,

Compare the simple SVG in the which the month works, to the complicated SVG in the which month does not work.

  1. Simple SVG
  2. Complicated SVG

The code in JavaScript in following:

<![CDATA[
function init() 
{
  var time = new Date();
  var locale = "en-gb";

  var DD   = time.getDate();
  var DDD  = time.toLocaleString(locale, {weekday: "long" });
  var MMM  = time.toLocaleString(locale, {month:   "long" });

  document.getElementById("day").textContent = DD;
  document.getElementById("weekday").textContent = DDD;
  document.getElementById("mes").textContent = MMM;
}
]]>

And in SVG where the month does not work:

<svg onload="init()" xmlns="http://www.w3.org/2000/svg" aria-label="calendar" width="256" height="256" style="isolation:isolate" viewBox="0 0 256 256">

<!--- (...) -->

    <g transform="matrix(1, 0, 0, 1, 67, 19.5)">
        <text id="mes" style="font-family: 'Overpass'; font-weight: 400; font-size: 24px; font-style: normal; fill: #FFFFFF; stroke: none; text-anchor: center" transform="matrix(1, 0, 0, 1, 0.124, 23.568)">
            September
        </text>
    </g>
</svg>