Cannot get default date or format with date TV

I’m trying to format the output of a date TV type.

I want:

  • the date output to default to ‘today’
  • to hide the time field
  • the date output format of %a %b %d, %Y

I have:

  • placed ‘today’ (without the ticks) in the Default Value field (as well as ‘now’)
  • placed ‘%a %b %d, %Y’ (without the ticks) in Output Options date format field
  • selected ‘Yes’ for the Hide Time option (I’m logged in as Manager, so perhaps this only works for non-Manager users?)

I get:

  • date output as 1999-11-30 (no matter the value placed in the Default Value field – yesterday, now, today)
  • date output not formatted as %a %b %d, %Y
  • the time field is displayed (again, maybe this is a permissions thing?)

The date_timezone system setting is properly set, and other instances of system-generated dates display accurately.

How do I achieve what I have described?

Are you talking about how the time is displayed in the manager or how it is output on the frontend?

In the manager you have to use the system settings manager_date_format and manager_time_format to change the format.

Thanks - I’m aware of the distinction.

My post explains the issue – the TV’s output does not display as expected.

So how exactly do you output your TV? Directly in a tag in the template [[*myDateTv]]?

If you are using a snippet like getResources to output the date, then you have to make sure that the TV is processed (property processTVs).

Directly into a resource.

If this was in getResources, without the proper tag format, there’d be output at all. That’s not the issue.

All this doesn’t make much sense. What you have done is all correct and should work.

There are no permissions involved. The “Hide Time option” is just a boolean value in JS. The default value “today” is converted with the standard PHP function strtotime. (If the snippet return strftime('%Y-%m-%d %H:%M:%S',strtotime('today')); gives you the right value then this should work too).

Are you sure you are looking at the right TV?

I tried replicating this in 2.8.3, but could not. All works as expected using your settings. What version of MODX are you running?

I placed the TV into a new resource, and get the expected output.

The template it was originally displayed on is used by NewsPublisher, but as mentioned above, I had the TV tag directly in the template – i.e. it was not brought in by NewsPublisher.

Scratching my head over the original output, though in my experience, instances like these are almost always a case of pilot error. The only change between yesterday and today is that I’ve restarted the server environment - not sure how that would be an impact.