Don't use language specific date formats

Created on 15 May 2017, over 7 years ago
Updated 9 June 2023, over 1 year ago

Don't use language specific date formats for start and end date, because the strtotime does not support other language than English. i.e. in simpleads.module there's a simpleads_node_presave function. Inside this, there's this code:

    if ($start_time != 0) {
      $node->field_ad_start_date[$node->language][0]['value'] = format_date($start_time, 'custom', 'm/d/Y h:i a');
    }
    if ($end_time != 0) {
      $node->field_ad_end_date[$node->language][0]['value'] = format_date($end_time, 'custom', 'm/d/Y h:i a');
    }

Use instead of this something like this:

    if ($start_time != 0) {
      $node->field_ad_start_date[$node->language][0]['value'] = format_date($start_time, 'custom', 'm/d/Y H:i');
    }
    if ($end_time != 0) {
      $node->field_ad_end_date[$node->language][0]['value'] = format_date($end_time, 'custom', 'm/d/Y H:i');
    }

Use 24 hour format and don't use any variable/attribute which will generate text, because on other languege i.e. on hungarian server it will return hungarian string (am -> de, pm -> du) and when you feed back into the strtotime it will return FALSE, because strtotime speaks just English.

This issue block all the non-english based sites.

πŸ› Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium golddragon007

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024