Invalid Date on iPad, but ok on other devices

I’m using custom:button-card to display the date an entity was last updated, which is basically the state of the entity. On my iPad, I get “Invalid Date”, but on Android and PC devices the date displays without error.

I’m not sure if it’s a formatting error in my HA code, or if there’s some setting I need to change on the iPad. The HA app is the most recent version, and the iPad mini is also on the updated software version (15.8.5).

On the PC and Android, it looks like this:
screenshot1

On the iPad, using the Home Assistant app, it looks like this:

The custom:button-card code is below, where the formatted date is a custom field:

type: custom:button-card
entity: sensor.ic_status_update
section_mode: true
name: Status Update
show_name: false
show_label: false
show_state: false
custom_fields:
  formatted_date: |
    [[[
      var date = new Date(entity.state);
      var options = { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false };
      return "Status Update: " + '\xa0' + date.toLocaleDateString('en-US', options).replace(":", "");
    ]]]
tap_action:
  action: call-service
  service: homeassistant.update_entity
  service_data:
    entity_id: sensor.ic_status_update
styles:
  card:
    - border: 3px solid darkslategray
  grid:
    - grid-template-columns: 0%
    - grid-template-rows: 0%
  custom_fields:
    formatted_date:
      - color: darkolivegreen
      - justify-self: left
grid_options:
  columns: 12
  rows: 1

1257:14
I don’t usually agree with iOS but that is not valid. But I guess android and PC just doesn’t care.
Why do you remove the colon?

1 Like