Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
comparing time
MattP
All-
How can I take a date from a DCR and change it to milliseconds, like the way perl uses the time function.
So, in a dcr, authors enter modules of content with active date ranges (I can capture anything, right now month, day, year). Then, I want to check if the current date in between the active dates. So rather than compare months, days and years, I would like to just compare the current time in milliseconds to the date range in the dcr in milliseconds. I can get the current time no problem,
$time = time;
but how do I convert
May 12 2003 to milliseconds?
Is there a different approach?
Thanks
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Find more posts tagged with
Comments
Migrateduser
Will this work for you?
$time = timelocal($sec,$min,$hours,$mday,$mon,$year);
$time = timegm($sec,$min,$hours,$mday,$mon,$year);
DESCRIPTION
These routines are the inverse of built-in perl fuctions localtime() and gmtime(). They accept a date as a six-element array, and return the corresponding time(2) value in seconds since the Epoch (Midnight, January 1, 1970). This value can be positive or negative.
More details here and an example at:
http://www.perldoc.com/perl5.6.1/lib/Time/Local.html
--
Interwoven Consultant
IMG_0718N.jpg
MattP
It is exactly what I am looking for. I can't get it to work for some reason. Here is what I am trying in my TPL...
I get templte cannot be generated. If I comment out the calctime, it works fine.
<iw_perl>
<![CDATA[
$calctime = timelocal(0,0,0,0,0,0);
$time = time;
iwpt_output("$time");
iwpt_output("$calctime");
]]>
</iw_perl>
Thanks in advance.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Migrateduser
Well, if you try to convert May 12, 3003 I think it will work fine.
$calctime = timelocal(0,0,0,0,0,0); is not working because it says $mday is not withing range (1..31)
Thanks
StoryTeller.ssd.zip
MattP
ok, got it. Thanks.
$day = 13;
$month = 4;
$year = 3;
$calctime = timelocal 0,0,0,$day,$month,$year;
$time = time;
iwpt_output("$time");
iwpt_output("$calctime");
]]>
</iw_perl>
now I can start to build my comparisons. Thanks for your help.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Adam Stoller
If you want to compare dates / time - you might want to look at Date::Manip - it's got a lot of very nice functions for doing things like this (and a whole lot more)
--fish
(Interwoven Senior Technical Consultant)
MattP
wow, your not kidding. Thanks!
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA