Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 26, 2007, 04:46 PM   #1
macaddict23
macrumors 6502
 
Join Date: Jun 2006
Location: MacVille, USA
How to add an automatic date-tracker to my site

I simply want to add the day's current date at the top of my site.
__________________
Think Different.

Last edited by macaddict23; Apr 26, 2007 at 06:35 PM.
macaddict23 is offline   0 Reply With Quote
Old Apr 26, 2007, 04:49 PM   #2
Nicolasdec
macrumors 65816
 
Nicolasdec's Avatar
 
Join Date: Dec 2006
Location: London, UK
This could work

PHP Code:
<?php
$nextWeek 
time() + (24 60 60);
                   
// 7 days; 24 hours; 60 mins; 60secs
echo 'Now:       'date('Y-m-d') ."\n";
echo 
'Next Week: 'date('Y-m-d'$nextWeek) ."\n";
// or using strtotime():
echo 'Next Week: 'date('Y-m-d'strtotime('+1 week')) ."\n";
?>
__________________
Macbook Pro 2.53GHz 4GB, 2.8GHz 4GB iMac
Canon 5D II, 24-105 L f/4, 70-300 DO f/4.5-5.6, 180 F/3.5 L, Lensbaby Composer.
Flickr
Nicolasdec is offline   0 Reply With Quote
Old Apr 26, 2007, 06:34 PM   #3
macaddict23
Thread Starter
macrumors 6502
 
Join Date: Jun 2006
Location: MacVille, USA
Nicolasdec. Where do I insert this in source code?
__________________
Think Different.
macaddict23 is offline   0 Reply With Quote
Old Apr 26, 2007, 06:38 PM   #4
EricNau
Moderator
 
EricNau's Avatar
 
Join Date: Apr 2005
Location: San Francisco, CA
This should also work:
Code:
<script>
var mydate=new Date() 
var year=mydate.getYear() 
if (year < 1000) year+=1900 
var day=mydate.getDay() 
var month=mydate.getMonth() 
var daym=mydate.getDate() 
if (daym<10) daym="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>
Is it a simple html website? ...You just insert the code where you want the date to appear.
EricNau is offline   0 Reply With Quote
Old Apr 26, 2007, 06:44 PM   #5
macaddict23
Thread Starter
macrumors 6502
 
Join Date: Jun 2006
Location: MacVille, USA
Yes, it's a simple HTML site.

So like this:

<code>
<html>
<head>
<title>Today's Journal</title>
</head>
<body>
<script>
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000) year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10) daym="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","Novem ber","December")
document.write(""+montharray[month]+" "+daym+", "+year+"")
</script>

<p> Lorem ipsum . . . . </p>
</body>
</html>
</code>
__________________
Think Different.
macaddict23 is offline   0 Reply With Quote
Old Apr 26, 2007, 06:53 PM   #6
EricNau
Moderator
 
EricNau's Avatar
 
Join Date: Apr 2005
Location: San Francisco, CA
Quote:
Originally Posted by macaddict23 View Post
Yes, it's a simple HTML site.

So like this:
Yes, exactly. You can also place it in a table, center it with <center> tags, etc. etc.
EricNau is offline   0 Reply With Quote
Old Apr 26, 2007, 07:01 PM   #7
CanadaRAM
macrumors G5
 
CanadaRAM's Avatar
 
Join Date: Oct 2004
Location: On the Left Coast - Victoria BC Canada
<How to add an automatic date-tracker to my site>

But remember, before your evening ends, you have to slip the GPS transponder into your date's pocket or handbag. Remember to turn it on, or else the link to Google Maps won't work...
__________________
Expert
Ex = former, no longer. Spurt = a leak, esp. when caused by water pressure. Expert = a has-been drip under pressure.
CanadaRAM is online now   0 Reply With Quote
Old Apr 26, 2007, 07:35 PM   #8
Nicolasdec
macrumors 65816
 
Nicolasdec's Avatar
 
Join Date: Dec 2006
Location: London, UK
Quote:
Originally Posted by macaddict23 View Post
Nicolasdec. Where do I insert this in source code?
Its a PHP script put it were you want.
__________________
Macbook Pro 2.53GHz 4GB, 2.8GHz 4GB iMac
Canon 5D II, 24-105 L f/4, 70-300 DO f/4.5-5.6, 180 F/3.5 L, Lensbaby Composer.
Flickr
Nicolasdec is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
VEZMA Tracker: GPS vehicle mileage and route tracker Paulooze iPhone and iPod touch Apps 0 Jan 30, 2014 06:06 AM
On Numbers How make a column add the date automatic Boxito Mac Applications and Mac App Store 0 Dec 13, 2013 11:26 AM
Automator - Add both time and date AndrejSPB OS X 10.8 Mountain Lion 2 Mar 9, 2013 02:02 AM
Automatic Date Setting: Possible Battery Hog donster28 iPhone 33 Oct 12, 2012 03:03 PM

Forum Jump

All times are GMT -5. The time now is 09:41 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC