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
Can a Warlock become Neutral Good?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
How old can references or sources in a thesis be?
Test if tikzmark exists on same page
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
How to test if a transaction is standard without spending real money?
How do I create uniquely male characters?
Can I make popcorn with any corn?
To string or not to string
What does CI-V stand for?
What defenses are there against being summoned by the Gate spell?
TGV timetables / schedules?
How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?
The magic money tree problem
How can I make my BBEG immortal short of making them a Lich or Vampire?
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
Mathematical cryptic clues
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
Show that if two triangles built on parallel lines, with equal bases have the same perimeter only if they are congruent.
Languages that we cannot (dis)prove to be Context-Free
What typically incentivizes a professor to change jobs to a lower ranking university?
The Two and the One
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
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;
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
New contributor
|
show 2 more comments
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
New contributor
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);
orshiftedValue = 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
|
show 2 more comments
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
New contributor
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
magento2 ui-form datepicker calendar
New contributor
New contributor
edited 2 days ago
Behzad kahvand
New contributor
asked Apr 3 at 23:23
Behzad kahvandBehzad kahvand
184
184
New contributor
New contributor
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);
orshiftedValue = 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
|
show 2 more comments
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);
orshiftedValue = 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
|
show 2 more comments
1 Answer
1
active
oldest
votes
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);
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
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
add a comment |
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);
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
add a comment |
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);
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);
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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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);
orshiftedValue = 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