Jump to content

Date and Time HTML code


Recommended Posts

Does anyone have some HTML code that works within Frog Learn that will display the Date and Time like

DD Month Year
HH:MM

That will automatically adjust to British Summer Time and back again?

Thanks in advance

 

I found this code on line but can't get it to work:

 

 

<script type="text/javascript">
function GetClock(){
var d=new Date();
var nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getYear();
if(nyear<1000) nyear+=1900;<p>
var nhour=d.getHours(),nmin=d.getMinutes(),ap;
if(nhour==0){ap=" AM";nhour=12;}
else if(nhour<12){ap=" AM";}
else if(nhour==12){ap=" PM";}
else if(nhour>12){ap=" PM";nhour-=12;}

if(nmin<=9) nmin="0"+nmin;

document.getElementById('clockbox').innerHTML=""+ndate+"/"+(nmonth+1)+"/"+nyear+" "+nhour+":"+nmin+ap+"";
}

window.onload=function(){
GetClock();
setInterval(GetClock,1000);
}
</script>
<div id="clockbox"></div>

 

Link to comment
Share on other sites

@Sue Busher See code below - there are loads of adaptations that can be made have a look at the .JS website for any tweaks in format but this will simply display the date on your page then you can style this as you see fit.

We used this for a pop up banner on our website which said which timetable week it was and some other useful info.

 


  
<p id="showDate"></p>


    
<script>
     
var a = moment().format('dddd Do MMMM');
$('#showDate').html(a);
     
     
jQuery(document).ready(function(){
        jQuery('#hideshow').on('click', function(event) {        
             jQuery('#content').toggle('hide');
        });
    });
</script>

 

Link to comment
Share on other sites

No problem @Sue Busher  if you're not adding heaps of code I'd perhaps just add a line of code to to the p tag itself - see code below.

<p style="font-size:30px; font-family:arial; color:red;" id="showDate"></p>


    
<script>
     
var a = moment().format('dddd Do MMMM');
$('#showDate').html(a);
     
     
jQuery(document).ready(function(){
        jQuery('#hideshow').on('click', function(event) {        
             jQuery('#content').toggle('hide');
        });
    });
</script>

 

Link to comment
Share on other sites

Hi,

FrogCode will be live, but hidden in Dickens.  We're "launching" it April 19th, but for those who are desperate for it earlier, we can sort set up earlier.   There won't be sharing to FrogStore on launch.  That development is underway, but we will be able to use the community to provide widgets.

 

Graham

Link to comment
Share on other sites

On 15/03/2017 at 14:51, Graham Quince said:

Sorry - there's nowhere for it to live until FrogCode comes online.

 

On 16/03/2017 at 09:38, Sue Busher said:

Gutted :(

@Sue Busher as soon as you get Dickens you will be able to use the Package Manager to import and install widgets and apps found here on the Community! It won't mean that you will be able to tailor the widgets to your own needs but it will give you something in the meantime :).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...