Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Looking for "Week of..." datestamp?
Hi.  Does anyone know of a program that can insert a datestamp into a
web page that refers to the current w?  We have a wly online
publication, whose front page is generated by PHP includes pulling
snippets from various articles during the w.  At the top of the
page I manually enter, "Articles for the W of August 23, 2004" (for
instance).

Might there be a program that can do this automatically?  (I looked at
various "Last Updated" scripts but that changes the date each time an
article is posted, of course.  I would instead like it to remain the
date of the w's start, in our case each Monday.)

Thanks.

Report this thread to moderator Post Follow-up to this message
Old Post
Sandy Bremmer
08-22-04 08:55 AM


Re: Looking for "Week of..." datestamp?
Sandy Bremmer wrote:
> Hi.  Does anyone know of a program that can insert a datestamp into
> a web page that refers to the current w?  We have a wly
> online publication, whose front page is generated by PHP includes
> pulling snippets from various articles during the w.  At the top
> of the page I manually enter, "Articles for the W of August 23,
> 2004" (for instance).
>
> Might there be a program that can do this automatically?  (I looked
> at various "Last Updated" scripts but that changes the date each
> time an article is posted, of course.  I would instead like it to
> remain the date of the w's start, in our case each Monday.)

In Perl you can for instance do:

our $time = time;
my $wday = (localtime $time)[6];
my ($mday,$mon,$year) =
(localtime $time - ($wday ? $wday - 1 : 6) * 86400 )[3..5];
my @months = qw/January February March April May June
July August September October November December/;
printf 'Articles for the W of %s %d, %d',
$months[$mon], $mday, $year+1900;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
08-22-04 01:55 PM


Re: Looking for "Week of..." datestamp?
On Sun, 22 Aug 2004 10:13:59 +0200, Gunnar Hjalmarsson
<noreply@gunnar.cc> wrote:

>Sandy Bremmer wrote: 
>
>In Perl you can for instance do:
>
>     our $time = time;
>     my $wday = (localtime $time)[6];
>     my ($mday,$mon,$year) =
>       (localtime $time - ($wday ? $wday - 1 : 6) * 86400 )[3..5];
>     my @months = qw/January February March April May June
>       July August September October November December/;
>     printf 'Articles for the W of %s %d, %d',
>       $months[$mon], $mday, $year+1900;

Wow.  Thank you!!

Sandy


Report this thread to moderator Post Follow-up to this message
Old Post
Sandy Bremmer
08-22-04 01:55 PM


Re: Looking for "Week of..." datestamp?
Gunnar Hjalmarsson wrote:
> In Perl you can for instance do:
>
>      our $time = time;
>      my $wday = (localtime $time)[6];
>      my ($mday,$mon,$year) =
>        (localtime $time - ($wday ? $wday - 1 : 6) * 86400 )[3..5];
>      my @months = qw/January February March April May June
>        July August September October November December/;
>      printf 'Articles for the W of %s %d, %d',
>        $months[$mon], $mday, $year+1900;

Which roughly translates into the following PHP code:

<?

$time = time();
list (,,,,,,$wday) = localtime($time);

list (,,,$mday,$mon,$year) = localtime(
$time - ($wday ? $wday - 1 : 6) * 86400
);

$months = explode(
" ",
"January February March April May June " .
"July August September October November " .
"December"
);

printf(
'Articles for the W of %s %d, %d',
$months[$mon], $mday, $year + 1900
);

?>


JW




Report this thread to moderator Post Follow-up to this message
Old Post
Janwillem Borleffs
08-22-04 08:57 PM


Re: Looking for "Week of..." datestamp?
On Sun, 22 Aug 2004 15:43:20 +0200, "Janwillem Borleffs"
<jw@jwscripts.com> wrote:

>Gunnar Hjalmarsson wrote: 
>
>Which roughly translates into the following PHP code:
>
><?
>
>$time = time();
>list (,,,,,,$wday) = localtime($time);
>
>list (,,,$mday,$mon,$year) = localtime(
>     $time - ($wday ? $wday - 1 : 6) * 86400
> );
>
>$months = explode(
>     " ",
>     "January February March April May June " .
>     "July August September October November " .
>     "December"
> );
>
>printf(
>     'Articles for the W of %s %d, %d',
>     $months[$mon], $mday, $year + 1900
> );
>
>?>

I know USENET is busy and we shouldn't waste notes space saying thank
you (done privately instead), but I'm sorry, I just can't ever accept
the amazing generosity of this medium and the people using it and not
say thanks publicly.  I suppose I'm a hopeless sentimentalist but it
never stops to amaze me how I can post a note that goes out to the
"world" and then get back (often within the hour) such helpful replies
from people I'll probably never know.

Okay, ramble over.  Thank you for this help, it works beautifully.

Sandy

Report this thread to moderator Post Follow-up to this message
Old Post
Sandy Bremmer
08-22-04 08:57 PM


Re: Looking for "Week of..." datestamp?
"Sandy Bremmer" <no_email@no_email_thanx.com> wrote in message
 news:udahi05ur9udk3fqj90c4mjo3uknunbo7g@
4ax.com...
>
> I know USENET is busy and we shouldn't waste notes space saying thank
> you (done privately instead), but I'm sorry, I just can't ever accept
> the amazing generosity of this medium and the people using it and not
> say thanks publicly.

don't worry. thanks are acceptable.
in fact, a note saying that a solution worked for you
is helpful. It tells other that there is no need to
find more solutions, and it helps anyone looking for
a similar solution later, when they ramble onto the thread.

gnari





Report this thread to moderator Post Follow-up to this message
Old Post
gnari
08-22-04 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:44 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.