Topic on Project:Support desk

Getting page last modified

2
80.194.78.100 (talkcontribs)

Hi,

I'm wanting to get the date that a page was last modified from the database. I've looked at the page_touched field of the page table and that is getting updated as I make changes. However, it seems to be in a weird format - 3230313430313137313034373338 - for example for the Main Page. However, when I look at the bottom of the Main Page in the browser it displays correctly - This page was last modified on 17 January 2014, at 10:47. I want to be able to convert the page_touched timestamp into a date in Java.

Any ideas?

Regards,

Sean

88.130.102.118 (talkcontribs)

Hi Sean,

I don't know how, meaning from where you use Java.

If it is running on the same server as MediaWiki, then you can use MySQL to get the content of the field page_touched. Btw. the field page_touched should contain a timestamp in the format yyyymmddhhmmss. I guess you see this strange output, because the field is binary. You have to convert the number, which you see there, to an integer before you can use it.

If Java is running on another machine, then you might want to query the API, especially prop=info, which also gives you the last-changed-date (example).

Reply to "Getting page last modified"