Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$date = # Path to Date ???

Status
Not open for further replies.

wolfgross

Technical User
Nov 27, 2003
4
0
0
AU
...the instructions say:

"Check with your web hosting company"

but my client is running his own server (windows) and doesn't know what they're talking about :)
and my knowledge of perl is absolutly silch.
This is what I have to configure in the variables:

$date = `/bin/date`; chop($date); # Path to Date


...someone can help?...THANK YOU!

wolf
 
Why are you using date????? External system calls for this is not required.

Use 'localtime()'

This is portable and will give you a unixtimestamp that can be converted into whatever format you want.

www# perldoc -f localtime
=item localtime EXPR

Converts a time as returned by the time function to a 9-element list
with the time analyzed for the local time zone. Typically used as
follows:

# 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);

All list elements are numeric, and come straight out of the C `struct
tm'. $sec, $min, and $hour are the seconds, minutes, and hours of the
specified time. $mday is the day of the month, and $mon is the month
itself, in the range C<0..11> with 0 indicating January and 11
indicating December. $year is the number of years since 1900. That
is, $year is C<123> in year 2023. $wday is the day of the week, with
0 indicating Sunday and 3 indicating Wednesday. $yday is the day of
the year, in the range C<0..364> (or C<0..365> in leap years.) $isdst
is true if the specified time occurs during daylight savings time,
false otherwise.

Note that the $year element is I<not> simply the last two digits of
the year. If you assume it is, then you create non-Y2K-compliant
programs--and you wouldn't want to do that, would you?

The proper way to get a complete 4-digit year is simply:

$year += 1900;

And to get the last two digits of the year (e.g., '01' in 2001) do:

$year = sprintf(&quot;%02d&quot;, $year % 100);

If EXPR is omitted, C<localtime()> uses the current time (C<localtime(time)>).

In scalar context, C<localtime()> returns the ctime(3) value:

$now_string = localtime; # e.g., &quot;Thu Oct 13 04:54:34 1994&quot;

This scalar value is B<not> locale dependent, see L<perllocale>, but
instead a Perl builtin. Also see the C<Time::Local> module
(to convert the second, minutes, hours, ... back to seconds since the
stroke of midnight the 1st of January 1970, the value returned by
time()), and the strftime(3) and mktime(3) functions available via the
POSIX module. To get somewhat similar but locale dependent date
strings, set up your locale environment variables appropriately
(please see L<perllocale>) and try for example:

use POSIX qw(strftime);
$now_string = strftime &quot;%a %b %e %H:%M:%S %Y&quot;, localtime;

Note that the C<%a> and C<%b>, the short forms of the day of the week
and the month of the year, may not necessarily be three characters wide.
 
...thank you siberian for your detailed answer :) but as I said before, I'm an absolute novice to this mystical world of programming.
I've got this script because someone has told me it's [bold]easy![/bold]
and that &quot;date&quot; thingy is just part of it.

eg
######################################################################
# CONFIGURE THE VARIABLES BELOW #
######################################################################
$recipient = 'competition@solosub.org'; # Your Email Address
$domain = ' # Your domain Address ALL LOWERCASE!!!! ex $description ='Thank you for contacting YOURDOMAIN.COM'; # Email subject line for admin notification
$description2 ='Thank you for contacting YOURDOMAIN.COM'; # Email subject line for your customer
$mailprog = 'SMTP:mail.solosub.org'; # Path to your Mail Program
$date = `/bin/date`; chop($date); # Path to Date
$autoresponder = 'no'; # yes to use autoresponder or no will skip the autoresponder feature
$database = 'flat'; # Set to flat, mysql, or none
$mysqlname = &quot;your mysql databasename&quot;; # If you don't use mysql, do not edit
$mysqlusername = &quot;your myql username&quot;; # If you don't use mysql, do not edit
$mysqlpassword = &quot;your mysql password&quot;; # If you don't use mysql, do not edit
############ Optional variables #############################################
$Field1 = 'Name:'; #Form field title
$Field2 = 'email'; #Form field title
$Field3 = ''; #Form field title
$Field4 = ''; #Form field title
$Field5 = ''; #Form field title

etc.etc.etc.


So what I gather, it would be OK to leave that &quot;date&quot; bit out and replace it with
use POSIX qw(strftime);
$now_string = strftime &quot;%a %b %e %H:%M:%S %Y&quot;, localtime;

as you can see, [bold]no comprehension[/bold] of the whole thing what so ever :) :)

thanks again...

wolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top