in reply to (Solved) Search::Elasticsearch date range
Hello bfdi533,
Unfortunately I do not have anything to contribute to your question, but as I was reading your question I noticed how you collect the `date`.
On the sample of code that you provide us you do not use all the following parameters anywhere $dt and $latest_dt. I assume you are using them somewhere else on your code.
The way that you collect the date it might work on LinuxOS but I guess it will not work on WindowsOS (I assume as I can test it). So in order to make your code able to be executable on all OS I propose the following solution.
test.pl
#!/usr/bin/perl use strict; use warnings; use Date::Manip; # I assume you do not want to use the underscore alternatively just ad +d it my $date = UnixDate(ParseDate("now"), "%Y-%m-%d %T"); print $date . "\n"; my $dt = `date +%F_%T`; chomp $dt; print $dt . "\n"; my $latest_dt; my $dateAlternativeFormat = UnixDate(ParseDate("now"), "%a %b %d %T %Z + %Y"); print "Starting run at: ".`date`; print "Starting run at: ".$dateAlternativeFormat."\n"; __END__ $ perl test.pl 2018-04-25 11:28:18 2018-04-25_11:28:18 Starting run at: Wed Apr 25 11:28:18 CEST 2018 Starting run at: Wed Apr 25 11:28:18 CEST 2018
I am using the module Date::Manip. It is not the easiest module that you can use but the date manipulations that you can do with this module are infinite. Some examples for future study Date::Manip::Examples. Regarding the format of the date when you want to alter it, you can read more about it here: Date::Manip::Date::PRINTF_DIRECTIVES.
Hope this helps for future usage. BR / Thanos
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Search::Elasticsearch date range
by bfdi533 (Friar) on Apr 25, 2018 at 14:21 UTC |