Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeff 74 posts 346 karma points
    Feb 15, 2016 @ 09:11
    Jeff
    0

    Displaying unpublish at date

    Hi,

    It is possible to display the unpubish at date on a page? I've tried to get this to display a couple of ways but not had any luck as of yet.

    Regards, Jeff

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Feb 15, 2016 @ 12:56
    Dan Diplo
    100

    I think you'll have to use the ContentService to do this (which means hitting the database). Something like:

        var contentService = UmbracoContext.Current.Application.Services.ContentService;
    
        var content = contentService.GetById(1153); // your Id
    
        DateTime? unpublishDate = content.ExpireDate;
    

    As I say, this hits the DB, so use with caution.

  • Jeff 74 posts 346 karma points
    Feb 16, 2016 @ 10:29
    Jeff
    0

    Thanks I'll give this a go, hitting the database might be ok as it will only be on one page which shouldn't be getting hit all of the time.

    Regards, Jeff

Please Sign in or register to post replies

Write your reply to:

Draft