Giter Site home page Giter Site logo

Comments (5)

soderlind avatar soderlind commented on August 27, 2024

I've been a bit reluctant to add dd/mm/yy as a valid time format since it's not a "valid" format, but .. ok, I'll add it to the next release. Thank you for the code sample.

from acf-field-date-time-picker.

squarestar avatar squarestar commented on August 27, 2024

I'm curious what is meant by 'dd/mm/yy ...[is] not a "valid" format'. Is this a coding issue or a convention issue? If conventional, dd/mm/yy is standard in Europe.

from acf-field-date-time-picker.

BIOSTALL avatar BIOSTALL commented on August 27, 2024

The format 'dd/mm/yy' is standard in the UK and this plugin didn't work when using that format. I'm not sure about the default format in other countries.

from acf-field-date-time-picker.

soderlind avatar soderlind commented on August 27, 2024

By "not valid" I mean that strtotime doesn't understand dd/mm/yy (see notes: "if the separator is a slash (/), then the American m/d/y is assumed").

If the requirements for running WordPress were PHP 5.3 I would have used DateTime::createFromFormat, but it's PHP 5.2.4 and hence I have to use strtotime .

from acf-field-date-time-picker.

soderlind avatar soderlind commented on August 27, 2024

Fixed, please test the latest version here at github

@BIOSTALL, I did this (to support d/m/y (i.e. a single 'd'), there are some countries using it:

function update_value( $value, $post_id, $field ) {
    $field = array_merge($this->defaults, $field);
    if ($value != '' && $field['save_as_timestamp'] == 'true') {
        if (preg_match('/^dd?\//',$field['date_format'] )) { //if start with dd/ or d/ (not supported by strtotime())
            $value = str_replace('/', '-', $value);
        }
        $value = strtotime( $value );
    }

    return $value;
}

from acf-field-date-time-picker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.