Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to insert automatic date in a website

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 26-05-2009
Member
 
Join Date: May 2009
Posts: 60
How to insert automatic date in a website
  

I am making a small website for my project work. I have done almost everything like the body, images, etc. Now I want codes to insert a automatic date in the website. Like the visitor views the web page on the internet he must be able to see the current date. Send me some codes to add a date in the web page.

Reply With Quote
  #2  
Old 26-05-2009
Member
 
Join Date: Apr 2008
Posts: 1,946
Re: How to insert automatic date in a website

The below is small script of java codes to add a date in the web page. You can edit it as per your need. By adding this into your website you will get an date listed in your website and it will change everyday.
HTML Code:
<script language="JavaScript" type="text/JavaScript">
var updMonths = ["1","2","3","4","5","6","7","8","9","10","11","12"];
var updDate = new Date(document.lastModified);
var updTxt = updDate.getDate() + '/'+updMonths[updDate.getMonth()]+'/'+updDate.getFullYear();
document.write(updTxt);
</script><noscript>Script for automatisk dato</noscript>
Reply With Quote
  #3  
Old 26-05-2009
Member
 
Join Date: May 2008
Posts: 2,004
Re: How to insert automatic date in a website

Below is my basic workout for your date issue. Copy the below codes and paste it in the place where you want to see the date. After that save your page and reload it. Check out weather it need some editing or not.
PHP Code:
<script>
var 
mydate=new Date() 
var 
year=mydate.getYear() 
if (
year 1000year+=1900 
var day=mydate.getDay() 
var 
month=mydate.getMonth() 
var 
daym=mydate.getDate() 
if (
daym<10daym="0"+daym 
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
var 
montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December"
document.write(""+montharray[month]+" "+daym+", "+year+""
</script> 
Reply With Quote
  #4  
Old 26-05-2009
Member
 
Join Date: Apr 2008
Posts: 1,997
Re: How to insert automatic date in a website

As you are just using a website for a project work here it is a simple one line code to insert a date in the web page. copy paste the code in the website html script. And just insert this and very important in your properties make sure .php is selected instead of html.
PHP Code:
<?
echo date('l, F j, Y');
?>
Reply With Quote
  #5  
Old 28-10-2009
Member
 
Join Date: Oct 2009
Posts: 1
Re: How to insert automatic date in a website

Im extremely new to all this (html, css and js) and was wondering If I wanted to put the date to be displayed somewhere on my website how can i display it in a txt box on my page, rather than only be displayed at the top of my page at current.
Im trying to add this code, (well not this exact code but something very similar) to my html/css webpage.

Thank you so much in advance,
-Max

Quote:
Originally Posted by Katty View Post
Below is my basic workout for your date issue. Copy the below codes and paste it in the place where you want to see the date. After that save your page and reload it. Check out weather it need some editing or not.
PHP Code:
<script>
var 
mydate=new Date() 
var 
year=mydate.getYear() 
if (
year 1000year+=1900 
var day=mydate.getDay() 
var 
month=mydate.getMonth() 
var 
daym=mydate.getDate() 
if (
daym<10daym="0"+daym 
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
var 
montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December"
document.write(""+montharray[month]+" "+daym+", "+year+""
</script> 
Reply With Quote
  #6  
Old 29-10-2009
Member
 
Join Date: Jan 2008
Posts: 1,512
Re: How to insert automatic date in a website

You can use the JavaScript date functions and the document.lastModified properties to get the date and print it out. If you want to put in the full word for "Mon" or "Jan", you just need to change the wording in the script.
Reply With Quote
  #7  
Old 03-02-2011
Member
 
Join Date: Feb 2011
Posts: 1
Re: How to insert automatic date in a website

Hi,

I used the code Katty posted (which is really useful, thx) but now I'm trying to figure out how to stylize the text (bold, underline, italics etc)... could anyone help me out?
Reply With Quote
  #8  
Old 05-02-2011
Member
 
Join Date: Feb 2011
Posts: 1
smile Re: How to insert automatic date in a website

Yes just paste before the script example <font size="6" face="Katy Berry" color="gray">
Reply With Quote
  #9  
Old 04-05-2012
Member
 
Join Date: May 2012
Posts: 2
Re: How to insert automatic date in a website

Quote:
Originally Posted by Katty View Post
Below is my basic workout for your date issue. Copy the below codes and paste it in the place where you want to see the date. After that save your page and reload it. Check out weather it need some editing or not.
PHP Code:
<script>
var 
mydate=new Date() 
var 
year=mydate.getYear() 
if (
year 1000year+=1900 
var day=mydate.getDay() 
var 
month=mydate.getMonth() 
var 
daym=mydate.getDate() 
if (
daym<10daym="0"+daym 
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
var 
montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December"
document.write(""+montharray[month]+" "+daym+", "+year+""
</script> 

Thank you very much
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to insert automatic date in a website"
Thread Thread Starter Forum Replies Last Post
Which is the best way to insert video on my website? Bontu Software Development 4 08-06-2011 08:14 AM
How to insert last date in excel 2010 Calum Windows Software 5 17-02-2010 11:07 PM
Insert date format in SQL via ASP Bansi_WADIA Software Development 4 04-12-2009 09:56 PM
How to Insert Google Map on Website Gomeler Tips & Tweaks 3 21-08-2009 12:50 PM
Script insert date in the name of my file Viensterrr Software Development 4 31-10-2008 07:18 PM


All times are GMT +5.5. The time now is 04:46 AM.