magento 2 custom calendar instead of core calendarHow to disable given date in default calendar?Add Date Picker and/or Validation To System Config Form Field ArrayWhat happened with Magento 2 Service Layer?Magento admin form date widget week number differs from jquery UI week numberUse Jalali calendaradding calendar on form field in magento 2 not working error 404Disable previous days in default Magento2 calendarMagento 2 UI Form datepicker, default date and strange behaviourEmail template for contact form in magento2.2.5?how to change magento 2 date.js form file

Languages that we cannot (dis)prove to be Context-Free

What defenses are there against being summoned by the Gate spell?

Dragon forelimb placement

Is it important to consider tone, melody, and musical form while writing a song?

To string or not to string

What are these boxed doors outside store fronts in New York?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

Why doesn't H₄O²⁺ exist?

Why dont electromagnetic waves interact with each other?

Why was the small council so happy for Tyrion to become the Master of Coin?

What do you call a Matrix-like slowdown and camera movement effect?

How does strength of boric acid solution increase in presence of salicylic acid?

Why do falling prices hurt debtors?

strToHex ( string to its hex representation as string)

How to test if a transaction is standard without spending real money?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

The use of multiple foreign keys on same column in SQL Server

Today is the Center

"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"

Minkowski space

Is it legal for company to use my work email to pretend I still work there?

How to say job offer in Mandarin/Cantonese?

What typically incentivizes a professor to change jobs to a lower ranking university?

the place where lots of roads meet



magento 2 custom calendar instead of core calendar


How to disable given date in default calendar?Add Date Picker and/or Validation To System Config Form Field ArrayWhat happened with Magento 2 Service Layer?Magento admin form date widget week number differs from jquery UI week numberUse Jalali calendaradding calendar on form field in magento 2 not working error 404Disable previous days in default Magento2 calendarMagento 2 UI Form datepicker, default date and strange behaviourEmail template for contact form in magento2.2.5?how to change magento 2 date.js form file






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I want to create jalaali calendar (persian calendar) instead of magento
core calendar for admin and front pages .



for this purpose I've added these lines to my requirejs-config in my module :



 'map': 
'*':
'mage/calendar' : 'MyNamespace_MyModule/js/persian_calendar',
'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/date_form'





persian date and gregorian date are completely different and they have different years , months and days name . I want to show persian date to user but save date as gregorian format to database .



for sending gregorian date to server I changed onShiftedValueChange
function , I do this in my custom date_form :



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValue, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);




by these code equivalent gregorian date was sent to server correctly , but
when I checking the value stored in database it's completely different and invalid , for example I sent this value : 4/14/2019 5:30 am , but magento convert it to : 0010-08-10 05:30:00 !!



I think maybe the format date in my custom date_form is different from format date in magento form php code , cause this problem , because when I changed this.outputDateTimeFormat parameter to for example : "YYYY/DD/MM HH:mm" , stored value was changed and it got valid format value ( for example : "2023-08-10 05:30:00" ) , but still it has different value from the value has sent and they aren't equivalent.



I don't know where magento check input date and change it to incorrect value .



Does anybody know where magento check date inputes and changing them ?
Or
Does anyone have a completely different idea for this purpose ?










share|improve this question









New contributor




Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • can you share your whole code for sending date to the server

    – magefms
    Apr 4 at 5:05











  • @magefms thanks for reply , I changed the question and added some changes to it , please check it again .

    – Behzad kahvand
    2 days ago











  • shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); or shiftedValue = jMoment.from(shiftedValue, 'fa', 'YYYY/MM/DD HH:mm').format(this.pickerDateTimeFormat);?

    – magefms
    2 days ago











  • @magefms shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); because calendar UI format date is : 'DD/MM/YYYY HH:mm' . this part works correctly and it convert persain date to valid gregorian date .

    – Behzad kahvand
    2 days ago












  • @magefms , when I check console when sending to server it still has correct gregorian value , but stored value in database is different later.

    – Behzad kahvand
    2 days ago


















2















I want to create jalaali calendar (persian calendar) instead of magento
core calendar for admin and front pages .



for this purpose I've added these lines to my requirejs-config in my module :



 'map': 
'*':
'mage/calendar' : 'MyNamespace_MyModule/js/persian_calendar',
'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/date_form'





persian date and gregorian date are completely different and they have different years , months and days name . I want to show persian date to user but save date as gregorian format to database .



for sending gregorian date to server I changed onShiftedValueChange
function , I do this in my custom date_form :



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValue, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);




by these code equivalent gregorian date was sent to server correctly , but
when I checking the value stored in database it's completely different and invalid , for example I sent this value : 4/14/2019 5:30 am , but magento convert it to : 0010-08-10 05:30:00 !!



I think maybe the format date in my custom date_form is different from format date in magento form php code , cause this problem , because when I changed this.outputDateTimeFormat parameter to for example : "YYYY/DD/MM HH:mm" , stored value was changed and it got valid format value ( for example : "2023-08-10 05:30:00" ) , but still it has different value from the value has sent and they aren't equivalent.



I don't know where magento check input date and change it to incorrect value .



Does anybody know where magento check date inputes and changing them ?
Or
Does anyone have a completely different idea for this purpose ?










share|improve this question









New contributor




Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • can you share your whole code for sending date to the server

    – magefms
    Apr 4 at 5:05











  • @magefms thanks for reply , I changed the question and added some changes to it , please check it again .

    – Behzad kahvand
    2 days ago











  • shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); or shiftedValue = jMoment.from(shiftedValue, 'fa', 'YYYY/MM/DD HH:mm').format(this.pickerDateTimeFormat);?

    – magefms
    2 days ago











  • @magefms shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); because calendar UI format date is : 'DD/MM/YYYY HH:mm' . this part works correctly and it convert persain date to valid gregorian date .

    – Behzad kahvand
    2 days ago












  • @magefms , when I check console when sending to server it still has correct gregorian value , but stored value in database is different later.

    – Behzad kahvand
    2 days ago














2












2








2








I want to create jalaali calendar (persian calendar) instead of magento
core calendar for admin and front pages .



for this purpose I've added these lines to my requirejs-config in my module :



 'map': 
'*':
'mage/calendar' : 'MyNamespace_MyModule/js/persian_calendar',
'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/date_form'





persian date and gregorian date are completely different and they have different years , months and days name . I want to show persian date to user but save date as gregorian format to database .



for sending gregorian date to server I changed onShiftedValueChange
function , I do this in my custom date_form :



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValue, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);




by these code equivalent gregorian date was sent to server correctly , but
when I checking the value stored in database it's completely different and invalid , for example I sent this value : 4/14/2019 5:30 am , but magento convert it to : 0010-08-10 05:30:00 !!



I think maybe the format date in my custom date_form is different from format date in magento form php code , cause this problem , because when I changed this.outputDateTimeFormat parameter to for example : "YYYY/DD/MM HH:mm" , stored value was changed and it got valid format value ( for example : "2023-08-10 05:30:00" ) , but still it has different value from the value has sent and they aren't equivalent.



I don't know where magento check input date and change it to incorrect value .



Does anybody know where magento check date inputes and changing them ?
Or
Does anyone have a completely different idea for this purpose ?










share|improve this question









New contributor




Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I want to create jalaali calendar (persian calendar) instead of magento
core calendar for admin and front pages .



for this purpose I've added these lines to my requirejs-config in my module :



 'map': 
'*':
'mage/calendar' : 'MyNamespace_MyModule/js/persian_calendar',
'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/date_form'





persian date and gregorian date are completely different and they have different years , months and days name . I want to show persian date to user but save date as gregorian format to database .



for sending gregorian date to server I changed onShiftedValueChange
function , I do this in my custom date_form :



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValue, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);




by these code equivalent gregorian date was sent to server correctly , but
when I checking the value stored in database it's completely different and invalid , for example I sent this value : 4/14/2019 5:30 am , but magento convert it to : 0010-08-10 05:30:00 !!



I think maybe the format date in my custom date_form is different from format date in magento form php code , cause this problem , because when I changed this.outputDateTimeFormat parameter to for example : "YYYY/DD/MM HH:mm" , stored value was changed and it got valid format value ( for example : "2023-08-10 05:30:00" ) , but still it has different value from the value has sent and they aren't equivalent.



I don't know where magento check input date and change it to incorrect value .



Does anybody know where magento check date inputes and changing them ?
Or
Does anyone have a completely different idea for this purpose ?







magento2 ui-form datepicker calendar






share|improve this question









New contributor




Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago







Behzad kahvand













New contributor




Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 3 at 23:23









Behzad kahvandBehzad kahvand

184




184




New contributor




Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Behzad kahvand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • can you share your whole code for sending date to the server

    – magefms
    Apr 4 at 5:05











  • @magefms thanks for reply , I changed the question and added some changes to it , please check it again .

    – Behzad kahvand
    2 days ago











  • shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); or shiftedValue = jMoment.from(shiftedValue, 'fa', 'YYYY/MM/DD HH:mm').format(this.pickerDateTimeFormat);?

    – magefms
    2 days ago











  • @magefms shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); because calendar UI format date is : 'DD/MM/YYYY HH:mm' . this part works correctly and it convert persain date to valid gregorian date .

    – Behzad kahvand
    2 days ago












  • @magefms , when I check console when sending to server it still has correct gregorian value , but stored value in database is different later.

    – Behzad kahvand
    2 days ago


















  • can you share your whole code for sending date to the server

    – magefms
    Apr 4 at 5:05











  • @magefms thanks for reply , I changed the question and added some changes to it , please check it again .

    – Behzad kahvand
    2 days ago











  • shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); or shiftedValue = jMoment.from(shiftedValue, 'fa', 'YYYY/MM/DD HH:mm').format(this.pickerDateTimeFormat);?

    – magefms
    2 days ago











  • @magefms shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); because calendar UI format date is : 'DD/MM/YYYY HH:mm' . this part works correctly and it convert persain date to valid gregorian date .

    – Behzad kahvand
    2 days ago












  • @magefms , when I check console when sending to server it still has correct gregorian value , but stored value in database is different later.

    – Behzad kahvand
    2 days ago

















can you share your whole code for sending date to the server

– magefms
Apr 4 at 5:05





can you share your whole code for sending date to the server

– magefms
Apr 4 at 5:05













@magefms thanks for reply , I changed the question and added some changes to it , please check it again .

– Behzad kahvand
2 days ago





@magefms thanks for reply , I changed the question and added some changes to it , please check it again .

– Behzad kahvand
2 days ago













shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); or shiftedValue = jMoment.from(shiftedValue, 'fa', 'YYYY/MM/DD HH:mm').format(this.pickerDateTimeFormat);?

– magefms
2 days ago





shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); or shiftedValue = jMoment.from(shiftedValue, 'fa', 'YYYY/MM/DD HH:mm').format(this.pickerDateTimeFormat);?

– magefms
2 days ago













@magefms shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); because calendar UI format date is : 'DD/MM/YYYY HH:mm' . this part works correctly and it convert persain date to valid gregorian date .

– Behzad kahvand
2 days ago






@magefms shiftedValue = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat); because calendar UI format date is : 'DD/MM/YYYY HH:mm' . this part works correctly and it convert persain date to valid gregorian date .

– Behzad kahvand
2 days ago














@magefms , when I check console when sending to server it still has correct gregorian value , but stored value in database is different later.

– Behzad kahvand
2 days ago






@magefms , when I check console when sending to server it still has correct gregorian value , but stored value in database is different later.

– Behzad kahvand
2 days ago











1 Answer
1






active

oldest

votes


















1














Try this, it might work:



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValueNew = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValueNew, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);







share|improve this answer























  • it doesn't work , it has same problem .

    – Behzad kahvand
    2 days ago






  • 1





    I found the problem , when I changed this.outputDateTimeFormat value to : "YYYY-MM-DD HH:mm" the problem was solved !!!

    – Behzad kahvand
    2 days ago











  • That's great :)

    – magefms
    2 days ago






  • 1





    thanks for your helping , god bless you .

    – Behzad kahvand
    2 days ago












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Behzad kahvand is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268643%2fmagento-2-custom-calendar-instead-of-core-calendar%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Try this, it might work:



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValueNew = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValueNew, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);







share|improve this answer























  • it doesn't work , it has same problem .

    – Behzad kahvand
    2 days ago






  • 1





    I found the problem , when I changed this.outputDateTimeFormat value to : "YYYY-MM-DD HH:mm" the problem was solved !!!

    – Behzad kahvand
    2 days ago











  • That's great :)

    – magefms
    2 days ago






  • 1





    thanks for your helping , god bless you .

    – Behzad kahvand
    2 days ago
















1














Try this, it might work:



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValueNew = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValueNew, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);







share|improve this answer























  • it doesn't work , it has same problem .

    – Behzad kahvand
    2 days ago






  • 1





    I found the problem , when I changed this.outputDateTimeFormat value to : "YYYY-MM-DD HH:mm" the problem was solved !!!

    – Behzad kahvand
    2 days ago











  • That's great :)

    – magefms
    2 days ago






  • 1





    thanks for your helping , god bless you .

    – Behzad kahvand
    2 days ago














1












1








1







Try this, it might work:



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValueNew = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValueNew, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);







share|improve this answer













Try this, it might work:



onShiftedValueChange: function (shiftedValue) 
var value,
formattedValue,
formattedValueUTC,
momentValue;

// this is very simple code that check if selected date is gregorian date or persian date
var englishYears = ["2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate = false;
for (var i = 0; i < 26; i++)
if (shiftedValue.indexOf(englishYears[i]) > -1)
englishDate = true;
break;



if (shiftedValue)

// if selected date was persian,I converted it to equivalent gregorian format, for converting dates I used https://github.com/jalaali/moment-jalaali library
if (!englishDate)
shiftedValueNew = jMoment.from(shiftedValue, 'fa', 'DD/MM/YYYY HH:mm').format(this.pickerDateTimeFormat);


// the rest codes are for magento itself
momentValue = moment(shiftedValueNew, this.pickerDateTimeFormat);
if (this.options.showsTime)
formattedValue = moment(momentValue).format(this.timezoneFormat);
formattedValueUTC = moment.tz(formattedValue, this.storeTimeZone).tz('UTC');
value = this.outputDateTimeToISO ?
formattedValueUTC.toISOString() :
formattedValueUTC.format(this.outputDateTimeFormat);
else
value = momentValue.format(this.outputDateFormat);

else
value = '';


if (value !== this.value())
this.value(value);








share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









magefmsmagefms

2,4312426




2,4312426












  • it doesn't work , it has same problem .

    – Behzad kahvand
    2 days ago






  • 1





    I found the problem , when I changed this.outputDateTimeFormat value to : "YYYY-MM-DD HH:mm" the problem was solved !!!

    – Behzad kahvand
    2 days ago











  • That's great :)

    – magefms
    2 days ago






  • 1





    thanks for your helping , god bless you .

    – Behzad kahvand
    2 days ago


















  • it doesn't work , it has same problem .

    – Behzad kahvand
    2 days ago






  • 1





    I found the problem , when I changed this.outputDateTimeFormat value to : "YYYY-MM-DD HH:mm" the problem was solved !!!

    – Behzad kahvand
    2 days ago











  • That's great :)

    – magefms
    2 days ago






  • 1





    thanks for your helping , god bless you .

    – Behzad kahvand
    2 days ago

















it doesn't work , it has same problem .

– Behzad kahvand
2 days ago





it doesn't work , it has same problem .

– Behzad kahvand
2 days ago




1




1





I found the problem , when I changed this.outputDateTimeFormat value to : "YYYY-MM-DD HH:mm" the problem was solved !!!

– Behzad kahvand
2 days ago





I found the problem , when I changed this.outputDateTimeFormat value to : "YYYY-MM-DD HH:mm" the problem was solved !!!

– Behzad kahvand
2 days ago













That's great :)

– magefms
2 days ago





That's great :)

– magefms
2 days ago




1




1





thanks for your helping , god bless you .

– Behzad kahvand
2 days ago






thanks for your helping , god bless you .

– Behzad kahvand
2 days ago











Behzad kahvand is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Behzad kahvand is a new contributor. Be nice, and check out our Code of Conduct.












Behzad kahvand is a new contributor. Be nice, and check out our Code of Conduct.











Behzad kahvand is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268643%2fmagento-2-custom-calendar-instead-of-core-calendar%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Sum ergo cogito? 1 nng

419 nièngy_Soadمي 19bal1.5o_g

Queiggey Chernihivv 9NnOo i Zw X QqKk LpB