Programming dealing with time and date. - Help me out, I'm new to this stuff.
hi,
just get the "now"-time with:
sub _now
{
my ( $offset ) = @_;
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = gmtime( time + $offset*3600 );
$year+=1900;
$mon+=1;
return( sprintf( "%04u-%02u-%02u %02u:%02u:%02u", ( $year, $mon, $mday, $hour, $min, $sec ) ) );
}
the first parameter is the users-time-offset in hours.
think it works.
ciao
Anti
----------
ps:watch my work in progress at
http://webhome.nu/
Anonymous posted this at 17:33 — 1st June 1999.
They have: 5,633 posts
Joined: Jan 1970
it works....
but i would add the server-time to the database, you will probably want to know the time your web-site has it's heaviest traffic. if you only save the local-times, it won't be easy..
cu
patrick
elara posted this at 02:13 — 2nd June 1999.
They have: 112 posts
Joined: Apr 1999
Hi,
I need some help on programming logic and pointers because I'm fairly new to the date/time of Perl programming. This is what I'm going to do:
I'm going to have a list of subscribers. Whenever the subscriber visits my site, I'll try to show their current time depending on their location.
I know I'm going to need their GMTs, but I'm quite confused right now, what values should I keep track in the database? And I'm not quite familar with the GMT stuff.
Anyone has written this kind of program which deals with GMT, time and dates?
Thanks in advance.
----------
Elara - Webmasters' Guide
http://elara.hypermart.net/
anti posted this at 23:11 — 2nd June 1999.
They have: 453 posts
Joined: Jan 1999
Hi Pat,
as far is I understood elara she just wanted to show the time to the user.
And she wanted to know which data she'll need from her database to calc the users localtime.
The offset (to gmt) and gmt are the only things needed for this.
The timestamps in my logfiles are always gmt.
ciao
Anti
elara posted this at 02:46 — 3rd June 1999.
They have: 112 posts
Joined: Apr 1999
anti,
Thanks for your help, upon looking the code, I think it will work. I'll test it out shortly.
I have one more thing to clarify. I possess something extra that female don't. Never mind about it, gender doesn't matters to me, proud to be a man though . No intention to offense the females here...
Later.
----------
Elara - Webmasters' Guide
http://elara.hypermart.net/
anti posted this at 19:14 — 7th June 1999.
They have: 453 posts
Joined: Jan 1999
hi elara,
sorry if i "guessed" your gender wrong. it's just that names ending in "a" are usually female.
sorry.
ciao
anti
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.