How to get dates from 2021 to 2022
Date format "MM/DD/YYYY 12:00" want to print/store in array every date from 03/14/2021 12:00 to 03/14/2022 12:00. Don't suggest the moment module
do you know?
how many words do you know
See also questions close to this topic
-
how to change prettier format for react native
my code formatting prettier didn't works well for react native, i don't understand where to config it but it works well with flutter
from this code
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( <View> <Text>Apps</Text> </View> ) }
it's formatted to this
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( < View > < Text > Apps < /Text> < /View> ) }
-
MarkLogic server-side JavaScript and XQuery
I am just starting using NoSQL MarkLogic DB and trying to choose for me the best query language to learn and use in future. On server side MarkLogic provides the possibility to use JavaScript API or XQuery API.
I want to receive an advice. Which language is better to concentrate on and learn? JavaScript or XQuery?
- Popover in chrome extension using js
-
How to convert YYYYMM to YYYY-MM datetime format without day?
I have two datasets that have monthly frequencies. For one of them,
df
, I had to aggregate some data to turn it from daily to monthly using the following code:df_grouped=df.groupby([df.index.to_period('M'),'City ID']).agg({'Estimated Population':'mean','Estimated Population_2019':'mean','Confirmed Rate':['mean','std'],'Death Rate':['mean','std'],'New Confirmed':'sum','New Deaths':'sum'}) df_grouped.index.rename(['Month','City ID'],inplace=True)
After doing these changes my dates became in the format
YYYY-MM
, for example:2020-01 2020-02 ... 2021-07
My other dataset,
df2
, has the date in formatYYYMM
, so I used the following code to convert it:df2['DATE'] = pd.to_datetime(df2['DATE'],format='%Y%m')
My new dates become in the format
YYYY-MM-DD
, where all theDD
become 01, as follows:2020-01-01 2020-02-01 ... 2021-07-01
How can I convert
df2
date now fromYYYY-MM-DD
toYYYY-MM
?I was thinking, maybe there is a way to convert straight from
YYYYMM
toYYYY-MM
? -
convert month of dates into sequence
i want to combine months from years into sequence, for example, i have dataframe like this:
stuff_id date 1 2015-02-03 2 2015-03-03 3 2015-05-19 4 2015-10-13 5 2016-01-07 6 2016-03-20
i want to sequence the months of the date. the desired output is:
stuff_id date month 1 2015-02-03 1 2 2015-03-03 2 3 2015-05-19 4 4 2015-10-13 9 5 2016-01-07 12 6 2016-03-20 14
which means feb'15 is the first month in the date list and jan'2016 is the 12th month after feb'2015
-
PHP | Parse specific german date format to yyyy-mm-dd
Hey I am struggling with a date format . I need to adjust the display of some dates in a wordpress project.
Its not a duplicate of This question I tried the suggestion over there and its not working with that specific date format.
What I have is
german date
in the formatD, d. MM yyyy
looking like this:Fr, 6. Mai 2022
I want to convert it to
yyyy-mm-dd
=2022-05-06
but I cant get it work. I have tried to use date_parse_from_format and date_create_from_format but it seems to fail because of the german month and day names.$date_german = 'Fr, 6. Mai 2022'; $date_english = 'Fri, 6. May 2022'; print_r(date_create_from_format('D, d. F Y', $date_german)); // doesn't work print_r(date_create_from_format('D, d. F Y', $date_english)); // works ()
Another try with IntlDateFormatter
$date = 'Fr, 6. Mai 2022'; $formatter = new IntlDateFormatter("de_DE", IntlDateFormatter::SHORT, IntlDateFormatter::NONE); $formatter->setPattern('D, d. F Y'); $unixtime=$formatter->parse($date); $datetime=new DateTime(); $datetime->setTimestamp($unixtime); echo $datetime->format('Y-m-d');
Not working either, it returns:
1970-01-01
because $unixtime is empty?I also tried to setLocale to de_DE before formatting, but still same problem.
-
Apache 2.4 never runs RewriteMap program
Since JavaScript cannot access HTTP header
Accept-Language
, I decided to pass this information to a custom cookie using .htaccess as follows:RewriteRule .* - [CO=HTTP-Accept-Language:%{HTTP:Accept-Language}:%{HTTP_HOST}:1:/]
However, I quickly realized that cookies values are not allowed to use some "special" characters, including semicolon, which is used within
Accept-Language
header.Therefore, I decided to use a simple RewriteMap program written in Perl to replace semicolons with underscore characters.
#!/usr/bin/perl $| = 1; while (<STDIN>) { s/;/_/g; print $_; }
In my httpd.conf I defined the RewriteMap with
LogLevel trace8 <IfModule rewrite_module> RewriteEngine on Mutex default RewriteMap lc int:tolower RewriteMap uc int:toupper RewriteMap escape int:escape RewriteMap myprg "prg:/etc/httpd/rewrite/myprg.pl" </IfModule>
and to test these RewriteMap functions, I modified my .htaccess as follows:
RewriteEngine On RewriteBase / RewriteRule .* - [CO=Test1:${uc:%{HTTP:Accept-Language}}:%{HTTP_HOST}:1:/] RewriteRule .* - [CO=Test2:${myprg:%{HTTP:Accept-Language}}:%{HTTP_HOST}:1:/]
Unfortunately, while uc RewriteMap function works fine, the external myprg doesn't.
With
LogLevel trace8
in place, I expected some useful information in log file. But all I found about this external script was this:map lookup OK: map=myprg key=en-US,en;q=0.9 -> val=
No error, just information that val is empty. Based on this finding, I modified my Perl script to include some internal logging:
#!/usr/bin/perl use Cwd qw(abs_path); use File::Spec; use POSIX; $| = 1; my (undef, $directory, $filename) = File::Spec->splitpath(abs_path($0)); open my $file, '>>:encoding(UTF-8)', $directory . ($filename =~ s/(?:\.[^.]*)$/.log/r); print {$file} (strftime "%F %T", localtime time) . "\tRewriteMap script $filename started\n"; close $file; while (<STDIN>) { s/;/?/g; print $_; }
After each change, I obviously also restarted Apache server by
systemctl restart httpd
Then I realized that my Apache 2.4.6 (CentOS) never run the external RewriteMap script myprg.
I spent hours researching a possible problem on my side, but I didn't find anything wrong in my configuration files. What am I doing wrong? Why do I see no error, no warning, despite the script is never called?
-
Convert Json string literals to utf8 characters with perl or bash
I have a file full of \u codes and want to replace them all with corresponding utf8 character, for example "\u00FC" will become "ü":
Here is how far I got:
echo 'f\u00FCr' | perl -C -p -e "s/\\\\(u[0-9A-Fa-f]{4})/ chr(hex(sprintf('0x%s', '00FC'))) /ge"
This will output the expected "für". I just can't figure out how to use the value of the capture group into the sprintf function? $1, $1, \1 and \1 are not working. Guess it will be something very simple, but don't know what to search for. :-)
Or if there is a better approach for this, please let me know, too!
-
regex meaning /^\[ ( .* ) \ ] $/
$row =~ /^\[(.*)\]$/
What does the above regex mean?