Generating sequence of dates

前端 未结 1 1646
北荒
北荒 2020-12-21 00:52

i would like to generate sequence of dates with next code:

vm1=strptime(\"2000-01-01 00:00:00\", format=\"%Y-%m-%d %H:%M:%S\")
vm2=strptime(\"2011-12-31 23:5         


        
相关标签:
1条回答
  • 2020-12-21 01:54

    That section of vm3 looks fine to me (UK locale, GMT/BST time zone). Consider forcing your dates to be in universal time, and then correcting to your local time zone later on.

    vm1=strptime("2000-01-01 00:00:00", format="%Y-%m-%d %H:%M:%S", tz = "UTC")
    vm2=strptime("2011-12-31 23:55:00", format="%Y-%m-%d %H:%M:%S", tz = "UTC")
    vm3=seq(vm1, vm2, by = "300 mins")
    any(is.na(vm3)) #FALSE
    

    BTW, you want a by argument of "300 mins", not min(300). min is the minimum function; it has nothing to do with minutes.

    0 讨论(0)
提交回复
热议问题