If you are trying to predict future values then it doesn't make sense to treat them as categorical features. There is nothing you will learn that can predict future data, since you won't see those times again.
The same holds even if you are trying to predict unseen past data but each time appears only once or a small number of times.
Instead the time values should determine the order of your training data. This way you can avoid leaking future data, and models with state can learn features from the sequential nature of the data.
However, in some cases you may want to extract additional features from the time values. Here are some examples:
- Time since last interesting event
- Number of interesting events in last time window of size n
- Time of day (morning / afternoon / etc)
- Day of week
- Holiday
- Season
Let's make up an example. Here is a dataset of times that users visited a website:
time user
2017-11-01 00:00 Alice
2017-11-01 00:00 Bob
2017-11-02 00:00 Chris
2017-11-03 00:00 Alice
2017-11-04 00:00 Alice
2017-11-04 00:00 Bob
2017-11-07 00:00 Chris
2017-11-10 00:00 Alice
And here is the same dataset with additional features we have added:
time user last_visit weekend? time_of_day
2017-11-01 16:22 Alice N/A No afternoon
2017-11-01 11:13 Bob N/A No morning
2017-11-02 20:35 Chris N/A No evening
2017-11-03 16:07 Alice 2 days No afternoon
2017-11-04 17:20 Alice 1 day Yes afternoon
2017-11-04 10:44 Bob 3 days Yes morning
2017-11-07 08:06 Chris 5 days No morning
2017-11-10 17:11 Alice 6 days No afternoon
If we are trying to predict when a certain user might visit next, then these features might help us a lot. For example we might decide that Alice is more likely to visit in the afternoon, or Bob is unlikely to visit two days in a row.