HTML time code

  • ali
  • Born
  • Born
  • ali
  • Posts: 4

Post 3+ Months Ago

Hello friends,
I am trying to find html code for Date and time (like: 2009-1-25, 9:28am) it is appreciated if anybody can help. thanks.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6254
  • Loc: Seattle, WA

Post 3+ Months Ago

Using Javascript,

Code: [ Select ]
now = new Date();


will set 'now' to a new Date object set to the current date and time.

http://www.w3schools.com/jS/js_obj_date.asp
  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

or you could use php
2009-1-25, 9:28am
Code: [ Select ]
 
<?php
print date('Y')."-".date('j')."-".date('n').", ".date('h').":".date('ia')
?>
 
  1.  
  2. <?php
  3. print date('Y')."-".date('j')."-".date('n').", ".date('h').":".date('ia')
  4. ?>
  5.  

note it will only show the time the page was loaded on it will not update to do that you need to reloaded the page.
  • naruto
  • Born
  • Born
  • naruto
  • Posts: 2

Post 3+ Months Ago

Code: [ Select ]
<table>
<td bgcolor="black" height="45">
<img src="dg8.gif" name="hr1"><img
src="dg8.gif" name="hr2"><img
src="dgc.gif" name="c"><img
src="dg8.gif" name="mn1"><img
src="dg8.gif" name="mn2"><img
src="dgc.gif" name="c"><img
src="dg8.gif" name="se1"><img
src="dg8.gif" name="se2"><img
src="dgpm.gif" name="ampm">
</td></table>

<script language="javascript"><!-- start
// created: 2000-2004 ricocheting.com
// htp://ww.ricocheting.com/js/

dg0 = new Image();dg0.src = "dg0.gif";
dg1 = new Image();dg1.src = "dg1.gif";
dg2 = new Image();dg2.src = "dg2.gif";
dg3 = new Image();dg3.src = "dg3.gif";
dg4 = new Image();dg4.src = "dg4.gif";
dg5 = new Image();dg5.src = "dg5.gif";
dg6 = new Image();dg6.src = "dg6.gif";
dg7 = new Image();dg7.src = "dg7.gif";
dg8 = new Image();dg8.src = "dg8.gif";
dg9 = new Image();dg9.src = "dg9.gif";
dgam= new Image();dgam.src= "dgam.gif";
dgpm= new Image();dgpm.src= "dgpm.gif";
dgc = new Image();dgc.src = "dgc.gif";

function dotime(){
theTime=setTimeout('dotime()',1000);
d = new Date();
hr= d.getHours()+100;
mn= d.getMinutes()+100;
se= d.getSeconds()+100;
if(hr==100){hr=112;am_pm='am';}
else if(hr<112){am_pm='am';}
else if(hr==112){am_pm='pm';}
else if(hr>112){am_pm='pm';hr=(hr-12);}
tot=''+hr+mn+se;
document.hr1.src = 'dg'+tot.substring(1,2)+'.gif';
document.hr2.src = 'dg'+tot.substring(2,3)+'.gif';
document.mn1.src = 'dg'+tot.substring(4,5)+'.gif';
document.mn2.src = 'dg'+tot.substring(5,6)+'.gif';
document.se1.src = 'dg'+tot.substring(7,8)+'.gif';
document.se2.src = 'dg'+tot.substring(8,9)+'.gif';
document.ampm.src= 'dg'+am_pm+'.gif';}
dotime();
//end -->
</script>
  1. <table>
  2. <td bgcolor="black" height="45">
  3. <img src="dg8.gif" name="hr1"><img
  4. src="dg8.gif" name="hr2"><img
  5. src="dgc.gif" name="c"><img
  6. src="dg8.gif" name="mn1"><img
  7. src="dg8.gif" name="mn2"><img
  8. src="dgc.gif" name="c"><img
  9. src="dg8.gif" name="se1"><img
  10. src="dg8.gif" name="se2"><img
  11. src="dgpm.gif" name="ampm">
  12. </td></table>
  13. <script language="javascript"><!-- start
  14. // created: 2000-2004 ricocheting.com
  15. // htp://ww.ricocheting.com/js/
  16. dg0 = new Image();dg0.src = "dg0.gif";
  17. dg1 = new Image();dg1.src = "dg1.gif";
  18. dg2 = new Image();dg2.src = "dg2.gif";
  19. dg3 = new Image();dg3.src = "dg3.gif";
  20. dg4 = new Image();dg4.src = "dg4.gif";
  21. dg5 = new Image();dg5.src = "dg5.gif";
  22. dg6 = new Image();dg6.src = "dg6.gif";
  23. dg7 = new Image();dg7.src = "dg7.gif";
  24. dg8 = new Image();dg8.src = "dg8.gif";
  25. dg9 = new Image();dg9.src = "dg9.gif";
  26. dgam= new Image();dgam.src= "dgam.gif";
  27. dgpm= new Image();dgpm.src= "dgpm.gif";
  28. dgc = new Image();dgc.src = "dgc.gif";
  29. function dotime(){
  30. theTime=setTimeout('dotime()',1000);
  31. d = new Date();
  32. hr= d.getHours()+100;
  33. mn= d.getMinutes()+100;
  34. se= d.getSeconds()+100;
  35. if(hr==100){hr=112;am_pm='am';}
  36. else if(hr<112){am_pm='am';}
  37. else if(hr==112){am_pm='pm';}
  38. else if(hr>112){am_pm='pm';hr=(hr-12);}
  39. tot=''+hr+mn+se;
  40. document.hr1.src = 'dg'+tot.substring(1,2)+'.gif';
  41. document.hr2.src = 'dg'+tot.substring(2,3)+'.gif';
  42. document.mn1.src = 'dg'+tot.substring(4,5)+'.gif';
  43. document.mn2.src = 'dg'+tot.substring(5,6)+'.gif';
  44. document.se1.src = 'dg'+tot.substring(7,8)+'.gif';
  45. document.se2.src = 'dg'+tot.substring(8,9)+'.gif';
  46. document.ampm.src= 'dg'+am_pm+'.gif';}
  47. dotime();
  48. //end -->
  49. </script>
Moderator Remark: Added code tags
  • zen4pokerbankrolls
  • Newbie
  • Newbie
  • zen4pokerbankrolls
  • Posts: 12

Post 3+ Months Ago

the javascript is working perfectly i just tried it.. thanks btw :)
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6254
  • Loc: Seattle, WA

Post 3+ Months Ago

Which Javascript did you just try? The code contained in the post above you contains references to dozens of images I'm sure you don't have.
  • JTcuy
  • Newbie
  • Newbie
  • JTcuy
  • Posts: 5

Post 3+ Months Ago

You can also try this:


Code: [ Select ]
<script language="JavaScript">
<!--
function getCorrectedYear(year) {
year = year - 0;
if (year < 70) return (2000 + year);
if (year < 1900) return (1900 + year);
return year;
}
        
var lmod = new Date();
var monthname;
var lmonth = lmod.getMonth();
if (lmonth == 0) monthname = "January";
if (lmonth == 1) monthname = "February";
if (lmonth == 2) monthname = "March";
if (lmonth == 3) monthname = "April";
if (lmonth == 4) monthname = "May";
if (lmonth == 5) monthname = "June";
if (lmonth == 6) monthname = "July";
if (lmonth == 7) monthname = "August";
if (lmonth == 8) monthname = "September";
if (lmonth == 9) monthname = "October";
if (lmonth == 10) monthname = "November";
if (lmonth == 11) monthname = "December";

var yearstr = getCorrectedYear(lmod.getYear());
        
var outstr = monthname + " " + lmod.getDate() + ", " + yearstr;
document.write(outstr);
// -->
</script>
  1. <script language="JavaScript">
  2. <!--
  3. function getCorrectedYear(year) {
  4. year = year - 0;
  5. if (year < 70) return (2000 + year);
  6. if (year < 1900) return (1900 + year);
  7. return year;
  8. }
  9.         
  10. var lmod = new Date();
  11. var monthname;
  12. var lmonth = lmod.getMonth();
  13. if (lmonth == 0) monthname = "January";
  14. if (lmonth == 1) monthname = "February";
  15. if (lmonth == 2) monthname = "March";
  16. if (lmonth == 3) monthname = "April";
  17. if (lmonth == 4) monthname = "May";
  18. if (lmonth == 5) monthname = "June";
  19. if (lmonth == 6) monthname = "July";
  20. if (lmonth == 7) monthname = "August";
  21. if (lmonth == 8) monthname = "September";
  22. if (lmonth == 9) monthname = "October";
  23. if (lmonth == 10) monthname = "November";
  24. if (lmonth == 11) monthname = "December";
  25. var yearstr = getCorrectedYear(lmod.getYear());
  26.         
  27. var outstr = monthname + " " + lmod.getDate() + ", " + yearstr;
  28. document.write(outstr);
  29. // -->
  30. </script>
Moderator Remark: Added [code] tags
  • JTcuy
  • Newbie
  • Newbie
  • JTcuy
  • Posts: 5

Post 3+ Months Ago

Or this:

Code: [ Select ]
<script language="JavaScript">

<!-- Begin

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Array list of months.
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number){
    return (number < 1000) ? number + 1900 : number;
                                }

// Join it all together
today = days[now.getDay()] + ", " +
        months[now.getMonth()] + " " +
        date + ", " +
        (fourdigits(now.getYear())) ;

// Print out the data.
document.write(today);

// End -->
</script>
  1. <script language="JavaScript">
  2. <!-- Begin
  3. // Get today's current date.
  4. var now = new Date();
  5. // Array list of days.
  6. var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  7. // Array list of months.
  8. var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
  9. // Calculate the number of the current day in the week.
  10. var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
  11. // Calculate four digit year.
  12. function fourdigits(number){
  13.     return (number < 1000) ? number + 1900 : number;
  14.                                 }
  15. // Join it all together
  16. today = days[now.getDay()] + ", " +
  17.         months[now.getMonth()] + " " +
  18.         date + ", " +
  19.         (fourdigits(now.getYear())) ;
  20. // Print out the data.
  21. document.write(today);
  22. // End -->
  23. </script>
Moderator Remark: Added [code] tags
  • san_sa_rocky
  • Beginner
  • Beginner
  • User avatar
  • Posts: 48
  • Loc: Dhaka, Bangladesh

Post 3+ Months Ago

javascript rules for it :) :)
  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

im not this much in with javascript but how would the display on a website?
  • roje0913
  • Student
  • Student
  • roje0913
  • Posts: 78

Post 3+ Months Ago

Just put the code where you want it to display, the print function is what is actually writing it

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 18 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.