PDA

View Full Version : how to show time stamp


anthony
03-31-2010, 06:49 PM
hey,

every time I make an update to a web page using dream weaver I want to be able to time stamp the post when the page is saved. does anyone know how to do this?

i know there is the feature "insert date" but I just want to insert 1 piece of code that does it automatically.

thanks
Anthony

edbr
04-01-2010, 01:09 AM
you need javascript
<SCRIPT LANGUAGE="JavaScript">
DaysofWeek = new Array() DaysofWeek[0]="Sunday" DaysofWeek[1]="Monday" DaysofWeek[2]="Tuesday" DaysofWeek[3]="Wednesday" DaysofWeek[4]="Thursday" DaysofWeek[5]="Friday" DaysofWeek[6]="Saturday"
Months = new Array() Months[0]="January" Months[1]="February" Months[2]="March" Months[3]="April" Months[4]="May" Months[5]="June" Months[6]="July" Months[7]="August" Months[8]="September" Months[9]="October" Months[10]="November" Months[11]="December"
RightNow = new Date()
var day = DaysofWeek[RightNow.getDay()] var date = RightNow.getDate() var Month = Months[RightNow.getMonth()] var Year = RightNow.getFullYear()
if (date == 1 || date == 21 || date == 31) {ender = "<SUP>st</SUP>"}
else if (date == 2 || date == 22) {ender = "<SUP>nd</SUP>"}
else if (date == 3 || date == 23) {ender = "<SUP>rd</SUP>"}
else {ender = "<SUP>th</SUP>"}
document.write("Today is " +day+ " " +Month+ " " +date+ ender+ ", " +Year+ ".") </SCRIPT>
or php

<? print(Date("l F d, Y")); ?> you can change this format as you want it to appear

DWcourse
04-01-2010, 03:36 AM
Use the insert date feature (menu: Insert>Date…) and in the Insert Date dialog check the Update automatically on save box.

Ricky55
04-01-2010, 07:36 PM
Better using PHP I think just in case Javascript is disabled in which case they won't work. Its just as easy to implement.

<?php ini_set('date.timezone', 'Europe/London');
echo date('l jS M Y'); ?>

DWcourse
04-01-2010, 07:56 PM
Don't both the javascript and php solutions just show the current date? I think he's after the date the file was last modified.

edbr
04-02-2010, 04:03 AM
in which case that can also be done with php