WordPress.org

Forums

[Plugin: Contact Form 7] Date submitted on form adds 1 day when emailed (3 posts)

  1. ericschwartz
    Member
    Posted 6 years ago #

    When a user submits the day, month and year of a wedding ceremony the emailed version adds one day to what the user submitted.

    Here is the date code:
    '<p><label>* Ceremony date: [select* Day "Day" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" ] [select Month "Month" "January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"] [select Year "Year" "2009" "2010" "2011" "2012" "2013" "2014" "2015"]</label></p>'

    Here is the code for the message body:
    'Ceremony Date: [Month] [Day] [Year]'

  2. webforge
    Member
    Posted 6 years ago #

    I had the same problem and solved it by prefixing single digit dates with a zero. The dates were then presumably handled as strings rather than numbers and the weird behaviour of adding 1 day stopped. So if you try the following, it should work properly:

    <p><label>* Ceremony date: [select* Day "Day" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" ] [select Month "Month" "January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"] [select Year "Year" "2009" "2010" "2011" "2012" "2013" "2014" "2015"]</label></p>

    Hope that helps :)

  3. webforge
    Member
    Posted 6 years ago #

    After testing the above "fix" more completely, I discovered that while the zero fix worked for single digit dates, dates in the teens i.e. 11, 12 13 etc. now appeared as 21, 22, 23 etc. and 20 and 21 also appeared as 30, 31. Dates in the twenties that were above 21 were okay as 32, 33 etc. were not in the range of 01 - 31. So to fix it, I made all dates into proper strings eg. 1st, 2nd, 3rd and so on. Rather inelegant, especially for non-english speaking users, but it works.

    For an otherwise great plugin, this bug makes the plugin almost unusable and definitely needs attention. Unfortunately I do not have time to wade through the php code to fix it properly, so hopefully the plugin developer (Takayuki Miyoshi) will address this issue in the next release.

    Anyway, the following cludge should fix it:

    <p><label>* Ceremony date: [select* Day "Day" "1st" "2nd" "3rd" "4th" "5th" "6th" "7th" "8th" "9th" "10th" "11th" "12th" "13th" "14th" "15th" "16th" "17th" "18th" "19th" "20th" "21st" "22nd" "23rd" "24th" "25th" "26th" "27th" "28th" "29th" "30th" "31st"] [select Month "Month" "January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"] [select Year "Year" "2009" "2010" "2011" "2012" "2013" "2014" "2015"]</label></p>

    Somehow or other, years are not affected by this bug, but if you use numbers for months, you will get similar weird behaviour. Hmmmm....

Topic Closed

This topic has been closed to new replies.

About this Topic