Hello. Thank you for contacting the Toolset support.
Well - the thing is that Toolset date custom field stores the date value as Unix timestamp. That is why the selected date field value in URL param shown as the UNIX timestamp but not as your desired date format.
What I suggest is you should try to catch the URL param value that is available as UNIX timestamp and convert it to your date format using the custom shortcode wherever you want to display its value.
Ideally the other plugin would be able to convert a unix time stamp to YYMMDD but it doesn't, although it accepts almost any date format !
The reason I am asking toolset is that this is easily achieved in a few minutes in a gravity form -- but but - but more than that either Views or the types custom field is generating this confusing parameter.
any idea this coming from ? it just looks like something in views is passing on a date format parameter which is just wrong - or as I thought i am missing an essential parm in the views filter.
thank you very much that's very helpful, unfortunately the &tbk_date=ddmmyyyy format I see now is problematic as its sometimes impossible to know what is a month and what is a day !
I thought this might be coming from the wordpress settings - but changing the Date Format under
Settings >> General
had no effect other than to change the output of the query parameter to make it confusing e.g.
&tbk_date=21032019&tbk_date-format=Y-m-d
I spent some time trying to understand hasDatepicker but was unable to find a way to change the date output format... and datepicker.
so I have two final questions / requests.
1. Do you think we can change the tbk_date=ddmmyyy param to tbk_date=yyyyyddmm using jQuery or should the wordpress date format setting be determining hasDatepicker format ?
2. Is it expected behavior for
&tbk_date-format=Y-m-d
to be sent as a url parameter - I ask as it serves no purpose other than add confusion.
thanks again - these are my only remaining questions in the area you have been so helpful assisting me in.
cheers
Well - what if you try to use the following code - just add it to your view's "search and pagination" sections JS box:
jQuery(document).ready(function ($) {
jQuery(".wpv-submit-trigger").on("click",function(){
datestr = $(".hasDatepicker").val();
var day = datestr.substring(0, 2);
var month = datestr.substring(2, 4);
var year = datestr.substring(4,8);
$("input[name='wpv-wpcf-birth-date']").val(year+day+month);
});
});
I made some minor modification and for the record the code which worked is:
jQuery(document).ready(function ($) {
jQuery(".wpv-submit-trigger").on("click",function(){
datestr = $(".hasDatepicker").val();
var day = datestr.substring(0, 2);
var month = datestr.substring(2, 4);
var year = datestr.substring(4,8);
$("input[name='tbk_date']").val(year+month+day);
});
});
I only leave this open in case you have some comment on the extraneous &tbk_date-format=Y-m-d..
Nicely resolved by Minesh with some out of the box thinking to overcome some functional limitations in the way dates are handled by views.
For the record this is an example based on some simple extension to the discover-wp travel destinations site using teambooking as the booking engine which accepts a query parameter to select a single date - and the code which worked is as follows:
/**
* Hide Submit Button - until Country and Date are selected
* get the date selected and convert to teambooking readable date
* name="tbk_date" is defined in the views filter as the url_param - and not the field name !
* [wpv-control-postmeta field="wpcf-tour-date" url_param="tbk_date"]
*/
jQuery(document).ready(function($){
$('input[name="wpv_filter_submit"]').hide();
jQuery(".wpv-submit-trigger").on("click",function(){
datestr = $(".hasDatepicker").val();
var day = datestr.substring(0, 2);
var month = datestr.substring(2, 4);
var year = datestr.substring(4,8);
$("input[name='tbk_date']").val(year+month+day);
});
});
jQuery("input[name='tbk_date']").on('change keyup paste', function () {
var value = jQuery('input[name="tbk_date"]').val();
if(value == '' || $('select[name="wpv-relationship-filter"]').val() == 0){
$('input[name="wpv_filter_submit"]').hide();
}else{
$('input[name="wpv_filter_submit"]').show();
}
});
jQuery("select[name='wpv-relationship-filter']").on('change', function () {
if($('select[name="wpv-relationship-filter"]').val() == 0 || jQuery('input[name="tbk_date"]').val()==''){
$('input[name="wpv_filter_submit"]').hide();
}else{
$('input[name="wpv_filter_submit"]').show();
}
});
jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
if($('select[name="wpv-relationship-filter"]').val() == 0 || jQuery('input[name="tbk_date"]').val()==''){
$('input[name="wpv_filter_submit"]').hide();
}else{
$('input[name="wpv_filter_submit"]').show();
}
});