Hiya,

content.getMetadata().getModificationDate() will return the date the content 
was last modified.
content.getMetadata().getLastActionDate() will return the date the content was 
last published / depublished.

In Magnolia 4.5 onwards you would use:

MetaDataUtil.getMetadata(node).getModificationDate()
MetaDataUtil.getMetadata(node).getLastActionDate()

However, unfortunately, the lastActionDate is never correct on the public 
instance, since this timestamp is updated only after the content is sent to the 
public system. Thus, on the public system lastActionDate always contains an 
"old" value, the date of the previous activation, not the current one.

If you really need the publication-date on the public server, you will need to 
create your own property to store this, and:
A) either have your editors manually enter the date, 
B) or automatically set the date when content is published

You can accomplish B) for example by creating a command for the "activation" 
command-chain on the author instance, or maybe by using the observation module 
on the public instances.
 
Regards from Vienna,

Richard


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] 
Im Auftrag von Christian Balaguer Jehle (via Magnolia Forums)
Gesendet: Dienstag, 25. September 2012 09:34
An: Magnolia User List
Betreff: [magnolia-user] Re: Get last published date of a page

If you are in the model of a paragraph you can get the activation/deactivation 
date as follows:

[code]
    //info.magnolia.cms.core.MetaData#getLastActionDate
    //Part of metadata, get last activated/de- date of the current node.

    Calendar cal =  content.getMetaData().getModificationDate();
    
    SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
    String formattedDate = df.format(cal.getTime()); [/code]

--
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=6371e2ee-5a74-4b37-9c68-d619123a5a4b


----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------


Email secured by Check Point




----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to