在R:从日期时间戳中提取时间时,出现错误的结果。更好的方法?

时间:2016-12-01 14:53:31

标签: r

您好我有以下数据时间戳数据帧'zz':

<p align="center">One day I was walking in a forest. I sat down to catch my breath. I saw a spider and it startled me. I continued walking and saw a river. It began to rain. I did not have my rain boots on. I started to get wet so I hid under a tree. When the rain stopped, I began to walk home.</p>

<div class="ul-holder">

    <div class="list">
    <ul>
        <li>
    <i class="fa fa-check"></i>   Item 1</li>
        <li>
    <i class="fa fa-check"></i>   Item 2</li>
        <li>
    <i class="fa fa-check"></i>   Item 3</li>
    </ul>
    </div>
    <div class="list">
    <ul>
        <li>
    <i class="fa fa-check"></i>   Item 4</li>
        <li>
    <i class="fa fa-check"></i>   Item 5</li>
        <li>
    <i class="fa fa-check"></i>   Item 6</li>
    </ul>
      
  </div>
  
</div>

当我运行以下内容时:

DateTimeStamp
27-08-12 10:33:49
30-08-12 10:03:47
10-09-12 10:59:01
11-09-12 10:48:47
27-08-12 0:00:00
30-08-12 0:00:00
10-09-12 0:00:00
11-09-12 0:00:00
13-10-12 0:00:00
06-11-12 0:00:00
15-12-12 0:00:00

我得到以下结果:

strftime(zz$DateTimeStamp[1:5], format = "%H:%M:%S")

这些显然是错误的。我做错了什么?

本地信息:

"13:33:49" "13:03:47" "13:59:01" "13:48:47" "03:00:00"

1 个答案:

答案 0 :(得分:0)

感谢@akrun并解决了最终问题。使用:

format(zz$DateTimeStamp, "%H:%M:%S")