Skip to content
Prev 359997 / 398503 Next

Query about use of format in strptime

Hi Stefano,
As the help page says:

"The default for the format methods is "%Y-%m-%d %H:%M:%S" if any
element has a time component which is not midnight, and "%Y-%m-%d"
otherwise. This is because when the result is printed, it uses the
default format. If you want a specified output representation:

format(strptime(init_day, format="%Y-%m-%d-%H-%M"),"%Y-%M-%d %H:%M")
[1] "2015-30-24 00:30"

For the "midnight" case:

format(strptime(init_day, format="%Y-%m-%d-%H-%M"),"%Y-%m-%d %H:%M")
[1] "2015-02-24 00:00"

Jim


On Mon, Apr 11, 2016 at 5:22 PM, Stefano Sofia
<stefano.sofia at regione.marche.it> wrote: