Forum Discussion

BradR's avatar
BradR
Khoros Alumni (Retired)
10 years ago

Finding messages edited over seven days ago

I'm trying to write what seems to be a simple little block of code, but I'm stumbling over how to manage the test in the #if block below.

 

<#assign messages = restadmin("/posts/recent?moderation.scope=unmoderated&visibility.scope=moderator").messages.message />
<#list messages as message>
	<#assign editDate = message.last_edit_time />
	<#if editDateIsOverSevenDaysAgo>
		<#-- DoSomething -->
	</#if>
</#list>

 

I'm kind of stuck because last_edit_time returns as a string and I'm not able to  convert it to something math friendly, nor am I able to identify any other way to get at this value.  Any thoughts?

2 Replies

  • AndrewF's avatar
    AndrewF
    Khoros Oracle
    10 years ago

    I haven't tried this, but I think this should work...

     

    Convert the string value to a date/time and then to a long integer value:

    editDate?datetime("yyyy-MM-dd hh:mm a")?long

     (That format string may be incorrect -- you might need to figure the right format string out)

     

    And get the current date as a long:

    .now?long

     then subtract them and compare to the number of milliseconds in seven days (604800000).