0% found this document useful (0 votes)
20 views4 pages

Todaysdate

This document outlines an experiment in web programming focused on developing a JavaScript script to display today's date. It explains the concepts of internal and external JavaScript, provides an implementation example, and discusses the benefits of using JavaScript for dynamic content. The conclusion emphasizes the effectiveness of the script in enhancing user experience by automatically displaying the current date.

Uploaded by

hetvi2032005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Todaysdate

This document outlines an experiment in web programming focused on developing a JavaScript script to display today's date. It explains the concepts of internal and external JavaScript, provides an implementation example, and discusses the benefits of using JavaScript for dynamic content. The conclusion emphasizes the effectiveness of the script in enhancing user experience by automatically displaying the current date.

Uploaded by

hetvi2032005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Web Programming (3160713)

Experiment No: 10

Develop a java script to display today’s date.

Date:

Competency and Practical Skills:

Relevant CO: 2

Objectives:

1. To understand how to write simple java script


Theory:

Javascript

● Javascript is a client side scripting language.


● HTML and CSS for static rendering of a page
● Scripting languages allows content to change dynamically
● Possible to interact with the user beyond what is possible with HTML
● Scripts are programs and can execute on the client side (the one with the browser) or
server.
● Running a script on the client saves processing time on the server
● Types Of Javascript

o Internal Javascript
▪ JavaScript code is placed in the head and body section of an HTML page.
▪ Example

o External JavaScript
▪ If you want to use the same script on several pages it could be good idea to
place the code in separate file, rather than writing it on each.
▪ JavaScript code are stored in separate external file using the .js extension
(Ex: external.js).

[Enrollment No: 220180107042]


Web Programming (3160713)
Example:
HTML File : index.html

External JavaScript file : external.js

Implementation:

Develop a java script to display today’s date.


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Today's Date</title>
</head>
<body>
<h1>Today's Date is: <span id="date"></span></h1>

<script>
const today = new Date();

const options = { year: 'numeric', month: 'long', day: 'numeric' };


const formattedDate = today.toLocaleDateString(undefined, options);
document.getElementById('date').textContent = formattedDate;
</script>
</body>
</html>

Output:

[Enrollment No: 220180107042]


Web Programming (3160713)

Conclusion:
The JavaScript provided effectively retrieves and displays the current date in a user-friendly format. By
using the built-in Date object and toLocaleDateString() method, it ensures accurate and localized date
formatting. This simple script can be easily integrated into any webpage to dynamically show today's
date. It enhances user experience by providing up-to-date information automatically. Overall, it's a
practical and efficient solution for displaying the current date on a website.

Quiz:

1. What is javascript?
Ans:
JavaScript is a high-level, interpreted programming language used primarily for web development. It
enables dynamic content, interactivity, and client-side scripting in web browsers. JavaScript can
manipulate HTML, CSS, and handle events, making web pages more interactive. It is also used in
server-side development (Node.js), mobile applications, and game development.

2. Explain internal and external javascript.


Ans:
Internal JavaScript
• Written within the HTML document inside the <script> tag.
• Placed in the <head> or <body> section.
• Useful for small scripts specific to a single page.
• Increases page load time as it is embedded directly in the HTML.
External JavaScript
• Stored in a separate .js file and linked to an HTML document using the <script> tag with the src
attribute.
• Promotes reusability and better code organization.
• Improves page loading speed as the script is loaded separately.
• Easier to maintain and update, especially for large projects.

Suggested Reference:

● https://www.w3schools.com/JSREF/jsref_obj_date.asp
References used by the students:

● https://www.w3schools.com/JSREF/jsref_obj_date.asp

Rubric wise marks obtained:

Rubrics 1 2 3 Total
Marks

[Enrollment No: 220180107042]


Web Programming (3160713)

[Enrollment No: 220180107042]

You might also like