hi,
ich habe eine frage zum Time Widget.
Im meiner PHP Formular wird das Datum immer um ein Tag hochgerechnet
strtotime("+1 day")
ich hab ein auch ein Kalende Widget wo ich das Datum selektieren kann.
Leider kann ich nicht den heutigen Tag selektieren, sondern IMMER +1 tag
Beispiel:
Ich moechte 30.09 selektieren, kann das aber nicht. Es wird mir der 1.10 angeboten.
PHP Formular so so aussieht:
time.widget.php sieht so aus:
Habt ihr da eine idee?
ich habe eine frage zum Time Widget.
Im meiner PHP Formular wird das Datum immer um ein Tag hochgerechnet
strtotime("+1 day")
ich hab ein auch ein Kalende Widget wo ich das Datum selektieren kann.
Leider kann ich nicht den heutigen Tag selektieren, sondern IMMER +1 tag
Beispiel:
Ich moechte 30.09 selektieren, kann das aber nicht. Es wird mir der 1.10 angeboten.
PHP Formular so so aussieht:
PHP:
<?php include_once VIEWS_PATH . 'Helpers/time.widget.php'; ?>
<?php include_once VIEWS_PATH . 'Front/elements/menu.php'; ?>
<?php
$STORAGE = &$_SESSION[$controller->default_product][$controller->default_order];
?>
<div class="pbPage">
<div class="pbPageTop"></div>
<div class="pbPageMiddle pbP20">
<form action="" method="post" class="pbForm">
<div class="pbParagraph">
<label class="pbLabel pbFloatLeft pbW150 pbPt5"><?php echo $PB_LANG['front']['1_start']; ?></label>
<input type="text" id="pb_date_from" name="date_from" class="pbText pbPointer pbMr5 pbW100 pbFloatLeft" value="<?php echo isset($STORAGE) && isset($STORAGE['date_from']) ? htmlspecialchars($STORAGE['date_from']): date($tpl['option_arr']['date_format'], strtotime("+1 day")); ?>" readonly="readonly" />
<a href="<?php echo $_SERVER['PHP_SELF']; ?>" class="pbDatepickerIcon pbMr5" id="pbDateFrom"></a>
<?php
$hf = isset($STORAGE) && isset($STORAGE['hour_from']) ? $STORAGE['hour_from'] : 9;
$mf = isset($STORAGE) && isset($STORAGE['minutes_from']) ? $STORAGE['minutes_from'] : null;
?>
<?php TimeWidget::hour($hf, 'hour_from', 'pb_hour_from', 'pbSelect pbMr5'); ?>
<?php TimeWidget::minute($mf, 'minutes_from', 'pb_minutes_from', 'pbSelect'); ?>
</div>
<div class="pbParagraph">
<label class="pbLabel pbFloatLeft pbW150 pbPt5"><?php echo $PB_LANG['front']['1_end']; ?></label>
<input type="text" id="pb_date_to" name="date_to" class="pbText pbPointer pbMr5 pbW100 pbFloatLeft" value="<?php echo isset($STORAGE['date_to']) ? htmlspecialchars($STORAGE['date_to']) : date($tpl['option_arr']['date_format'], strtotime("+2 day")); ?>" readonly="readonly" />
<a href="<?php echo $_SERVER['PHP_SELF']; ?>" class="pbDatepickerIcon pbMr5" id="pbDateTo"></a>
<?php
$ht = isset($STORAGE) && isset($STORAGE['hour_to']) ? $STORAGE['hour_to'] : 9;
$mt = isset($STORAGE) && isset($STORAGE['minutes_to']) ? $STORAGE['minutes_to'] : null;
?>
<?php TimeWidget::hour($ht, 'hour_to', 'pb_hour_to', 'pbSelect pbMr5'); ?>
<?php TimeWidget::minute($mt, 'minutes_to', 'pb_minutes_to', 'pbSelect'); ?>
</div>
<div class="pbParagraph">
<label class="pbLabel pbFloatLeft pbW150 pbPt5"> </label>
<a href="#pbBreadcrumbsStep2" class="pbBtn pbBtnBlue pbBtnChooseSpace pbFloatLeft"><span class="pbBtnBlueLeft"></span><?php echo $PB_LANG['front']['btn_choose_space']; ?><span class="pbBtnBlueRightArr"></span></a>
</div>
<div class="pbError" style="display: none; margin: 0 0 0 155px"></div>
</form>
</div>
<div class="pbPageBottom"></div>
</div>
time.widget.php sieht so aus:
PHP:
<?php
class TimeWidget
{
function day($d = null, $name = 'day', $id = 'day', $class = 'select-mini', $empty = false)
{
?><select name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="<?php echo $class; ?>"><?php
if ($empty !== false && is_array($empty))
{
?><option value="<?php echo $empty['value']; ?>"><?php echo stripslashes($empty['title']); ?></option><?php
}
foreach (range(1, 31) as $v)
{
if (strlen($v) == 1)
{
$v = '0' . $v;
}
if (!is_null($d) && $v == $d)
{
?><option value="<?php echo $v; ?>" selected="selected"><?php echo $v; ?></option><?php
} else {
?><option value="<?php echo $v; ?>"><?php echo $v; ?></option><?php
}
}
?></select><?php
}
function month($m = null, $format = null, $name = 'month', $id = 'month', $class = 'select-mini', $empty = false)
{
?><select name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="<?php echo $class; ?>"><?php
if ($empty !== false && is_array($empty))
{
?><option value="<?php echo $empty['value']; ?>"><?php echo stripslashes($empty['title']); ?></option><?php
}
if (!is_null($format) && in_array($format, array('F', 'm', 'M', 'n')))
{
} else {
$format = "m";
}
foreach (range(1, 12) as $v)
{
if (strlen($v) == 1)
{
$v = '0' . $v;
}
if (!is_null($m) && $v == $m)
{
?><option value="<?php echo $v; ?>" selected="selected"><?php echo date($format, mktime(0, 0, 0, $v, 1, 2000)); ?></option><?php
} else {
?><option value="<?php echo $v; ?>"><?php echo date($format, mktime(0, 0, 0, $v, 1, 2000)); ?></option><?php
}
}
?></select><?php
}
function year($y = null, $left = null, $right = null, $name = 'year', $id = 'year', $class = 'select-mini', $empty = false)
{
?><select name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="<?php echo $class; ?>"><?php
if ($empty !== false && is_array($empty))
{
?><option value="<?php echo $empty['value']; ?>"><?php echo stripslashes($empty['title']); ?></option><?php
}
$curr_year = date("Y");
foreach (range($curr_year - (int) $left, $curr_year + 1 + (int) $right) as $v)
{
if (!is_null($y) && $v == $y)
{
?><option value="<?php echo $v; ?>" selected="selected"><?php echo $v; ?></option><?php
} else {
?><option value="<?php echo $v; ?>"><?php echo $v; ?></option><?php
}
}
?></select><?php
}
function hour($h = null, $name = 'hour', $id = 'hour', $class = 'select-mini', $attr = array(), $options=array())
{
$defaults = array('start' => 0, 'end' => 23, 'skip' => array());
$opts = array_merge($defaults, $options);
$attributes = NULL;
foreach ($attr as $k => $v)
{
if (!in_array($k, array('name', 'id', 'class')))
{
$attributes .= ' ' . $k . '="'.$v.'"';
}
}
?><select name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="<?php echo $class; ?>"<?php echo $attributes; ?>><?php
foreach (range($opts['start'], $opts['end']) as $v)
{
if (in_array($v, $opts['skip'])) continue;
if (strlen($v) == 1)
{
$v = '0' . $v;
}
if (!is_null($h) && $v == $h)
{
?><option value="<?php echo $v; ?>" selected="selected"><?php echo $v; ?></option><?php
} else {
?><option value="<?php echo $v; ?>"><?php echo $v; ?></option><?php
}
}
?></select><?php
}
function minute($m = null, $name = 'minute', $id = 'minute', $class = 'select-mini', $attr = array(), $step = 1, $options = array())
{
$defaults = array('start' => 0, 'end' => 59, 'skip' => array());
$opts = array_merge($defaults, $options);
$attributes = NULL;
foreach ($attr as $k => $v)
{
if (!in_array($k, array('name', 'id', 'class')))
{
$attributes .= ' ' . $k . '="'.$v.'"';
}
}
?><select name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="<?php echo $class; ?>"<?php echo $attributes; ?>><?php
foreach (range($opts['start'], $opts['end']) as $v)
{
if (in_array($v, $opts['skip'])) continue;
if ($step > 0 && $v % $step !== 0)
{
continue;
}
if (strlen($v) == 1)
{
$v = '0' . $v;
}
if (!is_null($m) && $v == $m)
{
?><option value="<?php echo $v; ?>" selected="selected"><?php echo $v; ?></option><?php
} else {
?><option value="<?php echo $v; ?>"><?php echo $v; ?></option><?php
}
}
?></select><?php
}
}
?>
Habt ihr da eine idee?
Zuletzt bearbeitet von einem Moderator: