Results 1 to 3 of 3

Thread: Javascript Date

  1. #1
    Join Date
    Aug 2013

    Javascript Date

    Hi all,

    I'm not a developer, I am just a teacher of primary school children. I want to have a small piece of code that can go into an embedded html box within Activ Primary. i know that javascript works in this embedded box, but things like php and the like, don't.

    Basically what I need is as follows:

    Whatever date I open the program, this embedded html box will display the date in this way:

    Saturday, 17 August 2013

    I have no idea how to code that, but it would make my everyday tasks so much easier. Basically all our class presentations have to have the long date and the short date as shown above, but we do not always know what date we will be opening particular files, so we have to write this down at the start of every lesson (time which means we have our backs to the children whilst writing on the board, and not actually greeting them into the room). Sounds rather trivial, but this really does make a huge difference.

    If the code could also format the way it looks i.e black font in Calibri 20pt which is aligned centrally on a yellow background with a black border, that would be even more amazing.

    I would be so grateful for any help people can offer.

    Thanks in advance.


  2. #2
    Join Date
    Dec 2012
    This should work for you.

    HTML Code:
    	#date {
    		background: yellow;
    		text-align: center;
    		vertical-align: center;
    		font-size: 20pt;
    		font-family: Calibri;
    		border: 2px solid #000;
    		padding: 10px;
    <div id="date">
    	var months = {
    		0: "January",
    		1: "February",
    		2: "March",
    		3: "April",
    		4: "May",
    		5: "June",
    		6: "July",
    		7: "August",
    		8: "September",
    		9: "October",
    		10: "November",
    		11: "December"
    	var days = {
    		0: "Sunday",
    		1: "Monday",
    		2: "Tuesday",
    		3: "Wednesday",
    		4: "Thursday",
    		5: "Friday",
    		6: "Saturday"
    	var today = new Date();
    	var longDate = days[today.getDay()]+", "+today.getDate()+" "+months[today.getMonth()]+" "+today.getFullYear();
    	var shortDate = today.getDate()+"/"+((today.getMonth()+1 < 10 ? "0" : "" )+(today.getMonth()+1))+"/"+(today.getFullYear()).toString().replace("20","");
    	document.getElementById('date').innerHTML = longDate+"<br/>"+shortDate;
    Last edited by iBeZi; 08-17-2013 at 02:04 PM.

  3. #3
    Join Date
    Aug 2013
    That is absolutely brilliant, thank you!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center