Php magento 2自定义日历,而不是核心日历
我想创建jalaali日历(波斯日历)而不是magento日历 管理和头版的核心日历 为此,我在模块中的requirejs配置中添加了以下行:Php magento 2自定义日历,而不是核心日历,php,jquery-ui,magento,magento2,persian-calendar,Php,Jquery Ui,Magento,Magento2,Persian Calendar,我想创建jalaali日历(波斯日历)而不是magento日历 管理和头版的核心日历 为此,我在模块中的requirejs配置中添加了以下行: 'map': { '*': { 'mage/calendar' : 'MyNamespace_MyModule/js/persian_calendar', 'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/eleme
'map': {
'*': {
'mage/calendar' : 'MyNamespace_MyModule/js/persian_calendar',
'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/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);
}
}
on移位值更改:函数(移位值){
var值,
格式化值,
格式值UTC,
动量值;
//这是一段非常简单的代码,用于检查所选日期是公历日期还是波斯日期
var englishYears=[“2018”、“2019”、“2020”、“2021”、“2022”、“2023”、“2024”、“2025”、“2026”,
"2027", "2028", "2029", "2030", "۲۰۱۸", "۲۰۱۹", "۲۰۲۰", "۲۰۲۱", "۲۰۲۲", "۲۰۲۳", "۲۰۲۴",
"۲۰۲۵", "۲۰۲۶", "۲۰۲۷", "۲۰۲۸", "۲۰۲۹", "۲۰۳۰"];
var englishDate=假;
对于(变量i=0;i<26;i++){
if(移位值.indexOf(englishYears[i])>-1){
englishDate=正确;
打破
}
}
if(移位值){
//若选择的日期是波斯语,我将其转换为等效的格里高利格式,用于转换我使用的日期https://github.com/jalaali/moment-jalaali 图书馆
如果(!englishDate){
shiftedValue=jMoment.from(shiftedValue'fa',DD/MM/YYYY HH:MM')。格式(this.pickerDateTimeFormat);
}
//其余代码用于magento本身
momentValue=力矩(移位值,this.pickerDateTimeFormat);
if(this.options.showtime){
formattedValue=时刻(momentValue).format(this.timezoneFormat);
formattedValueUTC=矩.tz(formattedValue,this.storeTimeZone).tz('UTC');
value=this.outputDateTimeToISO?
formattedValueUTC.toISOString():
formattedValueUTC.format(this.outputDateTimeFormat);
}否则{
value=momentValue.format(this.outputDateFormat);
}
}否则{
值=“”;
}
if(value!==this.value()){
这个.价值(价值),;
}
}
根据这些代码,等效的公历日期被正确地发送到服务器,但是
当我检查存储在数据库中的值时,它完全不同且无效,例如,我发送了此值:4/14/2019 5:30 am,但magento将其转换为:0010-08-10 05:30:00
我想我的自定义日期表单中的格式日期可能与magento表单php代码中的格式日期不同,这导致了这个问题,因为当我将这个.outputDateTimeFormat参数更改为例如:“YYYY/DD/MM HH:MM”时,存储值被更改,它得到了有效的格式值(例如:“2023-08-10 05:30:00”),但它的值仍然与发送的值不同,它们并不相等
我不知道magento在哪里检查输入日期并将其更改为不正确的值
有人知道magento在哪里检查和更改日期输入吗?
或
有人对此有完全不同的想法吗