Ask Your Question
1

How to read the actual date in ROS

asked 2017-10-24 09:17:46 -0600

erivera1802 gravatar image

Hey!, I would like to name some archives, which I create in a ROS node, with a string related to the actual date on which the node is called. I already have used Ros time, but I dont know what does this "absolute" time means. My code is:

ros::Time begin = ros::Time::now();
ROS_INFO("%d\n", begin.sec);

And the output is:

[ INFO] [1508853591.867555047, 1508853591.867143646]: 1508853591

My questions are, what does this "1508853591" means? And how could I get something like 24-10-2017-16:13 or like it?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2017-10-24 09:48:41 -0600

gvdhoorn gravatar image

updated 2017-10-24 09:52:36 -0600

It may not look like it, but you already have "the actual date" there. It's just encoded as a Unix Timestamp or epoch, which is:

the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970.

To convert it into a date-time string, see #q251966, or lookup any of the myriad ways to convert a Unix epoch into any other date-time representation. This is not ROS specific, so don't limit your searches to pages about it.

edit flag offensive delete link more

Comments

Thanks! That was exactly what i needed.

erivera1802 gravatar imageerivera1802 ( 2017-10-26 03:05:44 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-10-24 09:17:46 -0600

Seen: 2,439 times

Last updated: Oct 24 '17