CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
extracting the date from the server and printing to a file

 



rottweiler
Deleted

May 31, 2000, 7:36 AM

Post #1 of 3 (398 views)
extracting the date from the server and printing to a file Can't Post

I have a shopping basket which drops a text file onto the secure server. The text file needs a date of transaction. I have found the date command as "/bin/date" and have tried to print the contents to the text file.
I get no errors at all the basket still works but the word date and the date from the server is still missing.
To print to the text file i have used this instruction print LOCALFILE "DATE -$date\n\n";


mckhendry
Deleted

May 31, 2000, 2:01 PM

Post #2 of 3 (398 views)
Re: extracting the date from the server and printing to a file [In reply to] Can't Post

Try using the localtime subroutine.

example:

my @time = &localtime();

but you will have to add 1900 to get the current year, example:

$time[5] += 1900;

you would then do this to print out today's date.

print "$time[4] $time[3], $time[5]\n";

hope this helps

[This message has been edited by mckhendry (edited 05-31-2000).]


DrZed
User

Jun 6, 2000, 7:58 AM

Post #3 of 3 (398 views)
Re: extracting the date from the server and printing to a file [In reply to] Can't Post

Also, you can simply use the following:

$date=localtime(time);
print "$date\n";

This will give you a date in the following format:
Tue Jun 6 11:54:58 2000

Also note that you can use gmtime() in place of localtime().

Using the array is fine if you want to extract elements, or to use numbers instead of text. This is simply another option.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives