Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Gravity Form - expiration date with year

I need help with this code. This code's output is example "21st of June". I would like to add year on that. How can I insert that in the code as I got an invalid code when I added the 'Y':)

add_filter( 'gform_field_value', 'all_the_dates', 10, 3 );
function all_the_dates( $value, $field, $name,  ) {
    // "21st of June" is the format we want
    $local_timestamp = GFCommon::get_local_timestamp( time() );
    $expiration_timestamp = ( 86400 * 182 ) + $local_timestamp;
    $today = date_i18n( 'jS \of F', $local_timestamp, true );
    $expiration = date_i18n( 'jS \of F', $expiration_timestamp, true );
    $values = array(
        'todays_date' => $today,
        'three_days'  => $three,
        '182_days'  => $expiration,
    );
    return isset( $values[ $name ] ) ? $values[ $name ] : $value;
}

Appreciate any input as soon as anyone can :) Thank you!!!

Cheers, Liza

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think your error is coming from the fact that $three is undefined: 'three_days' => $three, Remove that line and see if your site still receives an error.

add_filter( 'gform_field_value', 'all_the_dates', 10, 3 );
    function all_the_dates( $value, $field, $name,  ) {
        // "21st of June" is the format we want
        $local_timestamp = GFCommon::get_local_timestamp( time() );
        $expiration_timestamp = ( 86400 * 182 ) + $local_timestamp;
        $today = date_i18n( 'jS \of F Y', $local_timestamp, true );
        $expiration = date_i18n( 'jS \of F Y', $expiration_timestamp, true );
        $values = array(
            'todays_date' => $today,
            '182_days'  => $expiration,
        );
        return isset( $values[ $name ] ) ? $values[ $name ] : $value;
    }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!