How to change topic date after import

I imported all my content, but I want the topic date of each new topic to change as if it was posted from today’s date, there is no additional posts per topic

It’s “Change Timestamp” in the topic wrench menu:

The dialog that pops up explains:

Please select the new timestamp of the topic. Posts in the topic will be updated to have the same time difference.

For what it’s worth, I was using the API and didn’t remember to set created_at to the actual post date.


Yeahhh I need to do this for 3,000+ posts though

Sounds like a job for the API: updateTopicTimestamp.

1 Like

You can do it in rails. I think there might be an example somewhere if you search. Here’s a start.


But I would do some testing. Like, you’ll also want to update the posts?


There is no posts, only 1 topic/opening post in that topic, would the command you gave work out of the box?

The dialog box for changing the topic timestamp says:

Please select the new timestamp of the topic. Posts in the topic will be updated to have the same time difference.

If you change the date on the topic, it automatically fixes all the replies to be correct relative to the new date. So if a topic was originally dated on Jan. 1 and a reply on Jan. 5, changing the topic date to Jan. 2 will also update the reply to Jan. 6. Easy!

1 Like

Out of curiosity, why would you want all 3000+ topics to have the same date?

But, curiosity aside, you should be able to do this with the API or the rails console, if you’re comfortable using it (it’s good practice to take a backup first, just in case).

There’s some info about how to get the relevant API for things in this topic - Reverse engineer the Discourse API

And there are a few examples of different rails techniques in Administrative Bulk Operations that you could use to build what you need (or give you some idea of what to Search for).

1 Like

Just bumping this still need additional support please

Tried this, it doesn’t seem to make any changes but also gets no errors

To follow Jon’s suggestion, this is the Rails console version.

cd /var/discourse
./launcher enter app
rails c

Then, for a specific topic: Topic.with_deleted.find(TOPIC_ID), timestamp:!

For all topics without conditions:

Topic.find_each do |topic| topic, timestamp:!  
1 Like

You might also want to change updated_at.

1 Like