What is RSS?
how to get date before say 20 days ?
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > Perl web-programming > how to get date before say 20 days ? 24 July 2001 19:32:25

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

how to get date before say 20 days ?

Shweta Shah 24 July 2001 19:32:25
 hello,
is there something in perl through which i can get
date previous to some specified days ,say 20 days befores date
i need to know only dd-mm-yy and not time
is there any module function for it
thanks
shweta

Add comment
Sascha Kersken 24 July 2001 14:43:27 permanent link ]
 Hi!

The module Date::Calc provides a function AddDelta_Days().

It works like:

($year,$month,$day)­ = Add_Delta_Days($yea­r,$month,$day, $Dd);

where the result is a list consisting of year, month and date; the
arguments to the function are another year, month, date and a difference
number of days - which, in your case, can be -20.

So your problem could be solved like:

#!/usr/bin/perl -w
use Date::Calc;

($sec,$min,$hour,$m­day,$mon,$year) = localtime (time);
($oldyear, $oldmonth, $oldday) = Add_Delta_Days ($year, $month, $day,
-20);


Regards

Sascha

---------->Von: "shweta shah" <sshah@vertex.co.in­>>An: <beginners@perl.org­>>Betreff: how to get date before say 20 days ?>Datum: Die, 24. Jul 2001 13:24 Uhr>

hello,> is there something in perl through which i can get> date previous to some specified days ,say 20 days befores date> i need to know only dd-mm-yy and not time> is there any module function for it> thanks> shweta>
Add comment
Steve Howard 24 July 2001 14:47:00 permanent link ]
 Date::Calc has functions to make that very easy.

Steve H.

-----Original Message-----
From: shweta shah [mailto:sshah@vertex.co.in]
Sent: Tuesday, July 24, 2001 6:24 AM
To: beginners@perl.org
Subject: how to get date before say 20 days ?


hello,
is there something in perl through which i can get
date previous to some specified days ,say 20 days befores date
i need to know only dd-mm-yy and not time
is there any module function for it
thanks
shweta


Add comment
Craig Moynes/Markham/IBM 24 July 2001 15:44:25 permanent link ]
 
hello,>is there something in perl through which i can get>date previous to some specified days ,say 20 days befores date>i need to know only dd-mm-yy and not time>is there any module function for it>thanks>shweta

I have seen several people mention Date::Calc, I believe that is overkill
for your situation.

Take a look at the localtime function (perldoc -f localtime).
This will dump the date you specified into epoch time and then you can
subtract the specified days (converted into seconds) from that number.



-------------------­--------------------­--
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
cmoynes@ca.ibm.com

Add comment
Luke Bakken 24 July 2001 18:14:14 permanent link ]
 time() and locatime() functions are all you need, plus you need to figure
out the number of seconds in 20 days :-)­


On Tue, 24 Jul 2001, shweta shah wrote:
hello,> is there something in perl through which i can get> date previous to some specified days ,say 20 days befores date> i need to know only dd-mm-yy and not time> is there any module function for it> thanks> shweta>

Add comment
Jeff 'japhy/Marillion' Pinyan 24 July 2001 19:32:25 permanent link ]
 On Jul 24, shweta shah said:
is there something in perl through which i can get>date previous to some specified days ,say 20 days befores date>i need to know only dd-mm-yy and not time>is there any module function for it

Apart from what others have said, you can't JUST take the localtime() of
time - 20 * 86400:

$n = time;
$t = $n - 20 * 86400;

$now = localtime($n);
$then = localtime($t);

That will fail in some cases, where daylight savings time comes on or
off. To safely do this math, you should get the time for today at NOON.

use Time::Local;

$n = timelocal(0,0,12, (localtime)[3,4,5]); # noon, today
$t = $n - 20 * 86400;

$now = localtime($n);
$then = localtime($t);

--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.co­m/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonk­s.com/ http://forums.perlg­uru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetr­ics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > Perl web-programming > how to get date before say 20 days ? 24 July 2001 19:32:25

see also:
create temp table in rule
date array
Most efficient way to hard-sort records
пройди тесты:
see also:
Reports from jemmy framework
documentum training
why not in frensh?

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .