For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > August 2004 > Looking for "Week of..." datestamp?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Looking for "Week of..." datestamp?
Sandy Bremmer

2004-08-22, 3:55 am

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.
Gunnar Hjalmarsson

2004-08-22, 8:55 am

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
Sandy Bremmer

2004-08-22, 8:55 am

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

Janwillem Borleffs

2004-08-22, 3:57 pm

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



Sandy Bremmer

2004-08-22, 3:57 pm

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
gnari

2004-08-22, 3:57 pm

"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




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com