Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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 offline   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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How To Add An Existing Code To xcode? MrJC Mac Programming 4 Nov 8, 2010 02:47 PM
How to add an exchange account to Mail NStocks OS X 0 Dec 3, 2009 03:48 PM
Asking landlord to add an escape clause to my lease dukebound85 Community Discussion 15 Jul 21, 2009 10:51 PM
How to add IMAP/POP3 support to my app? rubyruby iPhone/iPad Programming 6 Feb 1, 2009 03:16 PM
How to add an Eject Button to your menubar MacBytes MacBytes.com News Discussion 14 May 27, 2008 08:05 AM


All times are GMT -5. The time now is 11:48 PM.

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

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