Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
Using Jalali DatePicker but only use Gregorian Value


First of all, I'm noob :) I'm trying to replace a CodeIgniter application DateTimePicker with another library called "Persian Datepicker" (https://babakhani.github.io/PersianWebToolkit/doc/datepicker).
1. On the first try, I tried altField option:
I created another input with "Persian Datepicker" that filled the original value automatically with the converted format (using Jalali Moment). Everything works fine, Original input value format is correct, but somehow the value didn't save at all; It works Only when the original input is modified by the user.

$('#duedate.jdatepicker').persianDatepicker({
        format: "YYYY/MM/DD",
        initialValue: false,
        calendarType: "persian",
        observer: true,
        responsive: true,
        calendar: {
         persian: {
               locale: "en",
         }
        },
        onSelect: function() {
         var dataDue = $('#jalali_due.pdatepicker').val();
         var dueConv = moment.from(dataDue, 'fa', 'YYYY/MM/DD').format('YYYY-MM-DD');
         $('.altDue').val(dueConv);
        }
    });
  1. After I failed with that, I tried to completely replace the already existed DateTimePicker, with "Persian Datepicker". In this case, Jalali should be converted to Gregorian date right after the user selects it because the application only uses the Gregorian format. I couldn't do this either :( I tried the code below...
$('#startdate.jdatepicker').persianDatepicker({
        format: "YYYY/MM/DD",
        initialValue: false,
        calendarType: "persian",
        observer: true,
        responsive: true,
        calendar: {
         persian: {
               locale: "en",
         }
        },
        onSelect: function(year) {
         var self = this;
         var startData = self.calendar;
         if (startData = "persian") {
         $('#startdate.jdatepicker').val('/**Gregorian Format**/')
       } else {
         $('#startdate.jdatepicker').val('/**Gregorian Format**/')
       }
         
        }
    });

Please help me out with this; Also if there's a better solution, let me know.

The application uses https://xdsoft.net/jqplugins/datetimepicker/ for DateTime Picker

Regards,

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda