You can read the last run time for the scheduled task inside the command, using LastRun
property as below.
using Sitecore;
using Sitecore.Data.Items;
public void Execute(Item[] items, Sitecore.Tasks.CommandItem commandItem, Sitecore.Tasks.ScheduleItem scheduleItem)
{
var lastRunServerTime = DateUtil.ToServerTime(scheduleItem.LastRun);
}
Since the dates in Sitecore are stored in UTC Timezone
, you can convert the time retrieved using LastRun
property on the schedule item to server timezone using DateUtil
extension as above.
Hope this helps!!! Let me know in case you have any queries.
Last run
field from the schedule item, are you getting some issue. Can you please elaborate the issue a little more to suggest the appropriate solution.