Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-23-2001, 11:54 PM   #1
LQ Newbie
Registered: Feb 2001
Posts: 2

Rep: Reputation: 0


I'm new to this stuff and have searched hours but can't figure this one out and I'm sure someone knows this one.

I'm trying to add a date field to a web page on a Linux 6.2 box with apache 1.3. Under UNIX the path is usr/sbin/date to add the following:

Here is the command:
date_command = "/sbin/date";

$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);

Tuesday, January 30, 2001 at 17:22:00 (EST)

Any ideas?

Old 02-24-2001, 08:40 PM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121

I'm not exactly sure what you are asking for in you post. I assume you are trying to write a perl script to display the date in a cgi script. Your date commands are correct, so I guess you need help to display them? The perl script below, using your date commands, display the date in a web page. If this is not the answer you were looking for then please supply more details... by the way... any executables in an sbin directory should never be executable by non privileged users. My date exec is under /bin



$date_command = "/bin/date";
$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);

print "Content-type: text/html\n\n";
print "<HTML>";

print "$date\n";

print "</HTML>";
Old 02-24-2001, 09:32 PM   #3
LQ Newbie
Registered: Feb 2001
Posts: 2

Original Poster
Rep: Reputation: 0
Smile Re: Date setting in Linux or Apache

You know, I feel real stupid, but looking over your script I realized that I was looking in /usr/bin not /bin so I couldn't find the date command. Really dumb, could have prevented a lot of stress and hours of digging. On the other hand, I did learn a lot in the search about other topics so not a loss.

Thanks for the Reply!
Old 02-25-2001, 11:04 AM   #4
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,258

Rep: Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920Reputation: 3920
Perl has a bunch of builtin date stuff too. Something like this will also work:

print scalar(localtime);


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
setting time and date? maginotjr Slackware 7 06-28-2005 08:53 AM
setting date and time lynger Linux - Software 2 05-21-2004 12:10 AM
setting time and date trpn Linux - Software 5 11-07-2003 07:48 AM
Setting Date and Time prich Linux - Newbie 3 12-16-2002 02:28 PM
setting the date Nyc0n Linux - General 2 05-24-2002 02:56 AM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration