Add date to website

Hi
I’m trying to add the date to my website. The directions say to add this script to the head of the page. Im using XPRO… where would the head be?

<script type="text/javascript" src="js/date.js"></script>

Then im supposed to make a js file. Do i make a file or just add this code to the javascript in the customizer ?

// JavaScript Document

//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var monthname=new Array("January","February","March","April","May",
"June","July","August","September","October","November",
"December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", "
+ d.getFullYear();
//---------------   END LOCALIZEABLE   ---------------

TIA,
Rena

Hi Rena,

To add script to the head, you can add the code below in your child theme’s functions.php file.

function my_head_script() {
    ?>
        
    ADD YOUR SCRIPT HERE


    <?php
}
add_action('wp_head', 'my_head_script');

With regards to js code, you can add it directly in Customizer > Custom> Edit Global JS

Hope that helps

I did it! But it moves all over the page when you resize the page. How can I make it stay in one spot?

#date-location
{ display: inline-block; position: absolute; right: 225px; top: 220px;
text-align: left; background-color: #FFFFFF; border: 0px solid #006699; padding: 4px; z-index: 2; }

Hi There,

Could you please provide us with the URL to your sample page to check your issue, so that we can assist you with a possible workaround.

Thanks!

Sure, thank you. Its palilastudio.com

Hi There,

This custom CSS will make the date display static on the small devices:

@media (max-width: 979px){
    div#date-location {
        margin: 0 auto;
        display: block;
        text-align: center;
        position: static;
    }
}

Regards!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.