时间问题

发布于 2024-12-06 04:57:24 字数 1725 浏览 1 评论 0原文

这应该是一个简单的修复;

我目前有一个用于选择日期范围的日历:

http://protekco.com/index.php/en/reservations/1718-carvelle-drive-westpalm-beach.html

当在日历中选择日期时,它会填充 2入住和退房日期的输入字段。问题是,日历最初设置晚了 1 天,因此 9 月 22 日星期四实际上显示为 9 月 21 日星期四。我只能在天数上回显 +1,但输入框仍然显示错误的日期。本质上,我试图添加相同的 +1,但因为日期返回为 yyyy/mm/dd,所以 +1 作用不大。 这是代码:

$listsFrom = $this->lists['from'];
$selectedFrom = $listsFrom ? strtotime($listsFrom) : 0;

$listsTo = $this->lists['to'];
$selectedTo = $listsTo ? strtotime($listsTo) : $selectedFrom;

if ($selectedTo) {
    ADocument::addDomreadyEvent('Calendars.checkOut = ' . $selectedTo . ';');
}
if ($selectedFrom) {
    ADocument::addDomreadyEvent('Calendars.checkIn = ' . $selectedFrom . ';');
}

$listOperation = $this->lists['operation'];

ADocument::addDomreadyEvent('Calendars.operation = ' . $listOperation . ';');

有什么想法吗?

谢谢你!

编辑:

<td class="<?php echo implode(' ', $class); ?>" <?php if ($canReserveBox) { ?> id="day<?php echo $firstDay->Uts+84600000; ?>" onclick="Calendars.setCheckDate('day<?php echo $firstDay->Uts+84600000; ?>','<?php echo AHtml::getDateFormat($firstDay->date, ADATE_FORMAT_MYSQL_DATE, 0); ?>','<?php echo AHtml::getDateFormat($firstDay->date, ADATE_FORMAT_NORMAL); ?>')"<?php } ?> >
                <span class="date" >
                    <?php echo AHtml::getDateFormat($firstDay->date, ADATE_FORMAT_NICE_SHORT)+1; 
                    ?>
                </span>

这实际上是所谓的更改。 + 84600000 是我添加的,但它似乎没有多大作用。

This should be a simple fix;

I currently have a calendar for selecting a range of date:

http://protekco.com/index.php/en/reservations/1718-carvelle-drive-westpalm-beach.html

When the dates are selected in the calendar, it populates 2 input fields for Check in and Check out dates. The problem is, the calendar initially was set 1 day late, so Thursday Sept 22 actually showed as a Thursday Sept 21. I was able to just echo a +1 on the day count, but the input boxes still show the erroneous date. Essentially, I'm trying to add the same +1, but because the date is returned as yyyy/mm/dd, +1 doesn't do much.
Here is the code:

$listsFrom = $this->lists['from'];
$selectedFrom = $listsFrom ? strtotime($listsFrom) : 0;

$listsTo = $this->lists['to'];
$selectedTo = $listsTo ? strtotime($listsTo) : $selectedFrom;

if ($selectedTo) {
    ADocument::addDomreadyEvent('Calendars.checkOut = ' . $selectedTo . ';');
}
if ($selectedFrom) {
    ADocument::addDomreadyEvent('Calendars.checkIn = ' . $selectedFrom . ';');
}

$listOperation = $this->lists['operation'];

ADocument::addDomreadyEvent('Calendars.operation = ' . $listOperation . ';');

Any ideas?

Thank you!

Edit:

<td class="<?php echo implode(' ', $class); ?>" <?php if ($canReserveBox) { ?> id="day<?php echo $firstDay->Uts+84600000; ?>" onclick="Calendars.setCheckDate('day<?php echo $firstDay->Uts+84600000; ?>','<?php echo AHtml::getDateFormat($firstDay->date, ADATE_FORMAT_MYSQL_DATE, 0); ?>','<?php echo AHtml::getDateFormat($firstDay->date, ADATE_FORMAT_NORMAL); ?>')"<?php } ?> >
                <span class="date" >
                    <?php echo AHtml::getDateFormat($firstDay->date, ADATE_FORMAT_NICE_SHORT)+1; 
                    ?>
                </span>

This is what actually calls the changes. The + 84600000 is my addition, it doesn't seem to do much tho.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉酒的小男人 2024-12-13 04:57:24

如果日期是yyyy/mm/dd格式,首先使用 strtotime() 将其转换为时间戳,然后然后您可以再次使用它来添加一天。

$date = '2011/06/01';
$ts   = strtotime('+24 hours', strtotime($date));
$date = date('Y/m/d', $ts);

这只是一种可能的解决方案。

If the date is in yyyy/mm/dd format, first use strtotime() to convert it to a timestamp, and then you can use it again to add one day.

$date = '2011/06/01';
$ts   = strtotime('+24 hours', strtotime($date));
$date = date('Y/m/d', $ts);

That is just one possible solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文