안녕하세요..고수님들
초보자가 질문 드립니다.
아래 코드에는 마감일이 있는데요.. 여분필드 wr_10을 이용해서 시작일을 만들고 싶어서 마감일 코드를 복사해서 붙여 넣기를 해서 만들어 봐도 영 안 됩니다. 어디부터 어디까지 수정해야 해야 하는지 한 수 가르침 부탁드립니다.
Copy
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_PLUGIN_PATH.'/jquery-ui/datepicker.php');
if ($w == '') {
$write['as_update'] = date("Y-m-d 23:00:00", G5_SERVER_TIME + 86400 * 10);
}
$edate = date("Y-m-d", strtotime($write['as_update']));
$ehour = date("H", strtotime($write['as_update']));
$harr = array("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16" , "17", "18", "19", "20", "21", "22", "23");
<div class="form-group">
<label class="col-sm-2 col-xs-12 control-label" for="edate">마감일</label>
<div class="col-sm-3 col-xs-6">
<div class="control-label input-group input-group-sm">
<input type="text" name="edate" value="<?php echo $edate; ?>" id="edate" class="form-control input-sm" size="10" maxlength="10">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="control-label input-group input-group-sm">
<select id="ehour" name="ehour" class="form-control input-sm">
<?php
for($i=0; $i < count($harr); $i++) {
$selected = ($harr[$i] == $ehour) ? ' selected' : '';
echo '<option value="'.$harr[$i].'"'.$selected.'>'.$harr[$i].'</option>'.PHP_EOL;
}
?>
</select>
<span class="input-group-addon">시</span>
</div>
</div>
</div>
<script>
$(function(){
$("#edate").datepicker({ changeMonth: true, changeYear: true, dateFormat: "yy-mm-dd", showButtonPanel: true });
$("#wr_content").addClass("form-control input-sm write-content");
});
</script>
|
답변 2개 / 댓글 6개
채택된 답변
+20 포인트
2023-06-25 (일) 15:30:41
Copy
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_PLUGIN_PATH.'/jquery-ui/datepicker.php');
if ($w == '') {
$write['as_update'] = date("Y-m-d 23:00:00", G5_SERVER_TIME + 86400 * 10);
}
$edate = date("Y-m-d", strtotime($write['as_update']));
$ehour = date("H", strtotime($write['as_update']));
$harr = array("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16" , "17", "18", "19", "20", "21", "22", "23");
// 시작일 생성
if (!empty($write['wr_10'])) {
$sdate = date("Y-m-d", strtotime($write['wr_10']));
$shour = date("H", strtotime($write['wr_10']));
} else {
$sdate = date("Y-m-d");
$shour = date("H");
}
?>
<div class="form-group">
<label class="col-sm-2 col-xs-12 control-label" for="sdate">시작일</label>
<div class="col-sm-3 col-xs-6">
<div class="control-label input-group input-group-sm">
<input type="text" name="sdate" value="<?php echo $sdate; ?>" id="sdate" class="form-control input-sm" size="10" maxlength="10">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="control-label input-group input-group-sm">
<select id="shour" name="shour" class="form-control input-sm">
<?php
for($i=0; $i < count($harr); $i++) {
$selected = ($harr[$i] == $shour) ? ' selected' : '';
echo '<option value="'.$harr[$i].'"'.$selected.'>'.$harr[$i].'</option>'.PHP_EOL;
}
?>
</select>
<span class="input-group-addon">시</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-xs-12 control-label" for="edate">마감일</label>
<div class="col-sm-3 col-xs-6">
<div class="control-label input-group input-group-sm">
<input type="text" name="edate" value="<?php echo $edate; ?>" id="edate" class="form-control input-sm" size="10" maxlength="10">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="control-label input-group input-group-sm">
<select id="ehour" name="ehour" class="form-control input-sm">
<?php
for($i=0; $i < count($harr); $i++) {
$selected = ($harr[$i] == $ehour) ? ' selected' : '';
echo '<option value="'.$harr[$i].'"'.$selected.'>'.$harr[$i].'</option>'.PHP_EOL;
}
?>
</select>
<span class="input-group-addon">시</span>
</div>
</div>
</div>
<script>
$(function(){
$("#sdate").datepicker({ changeMonth: true, changeYear: true, dateFormat: "yy-mm-dd", showButtonPanel: true });
$("#edate").datepicker({ changeMonth: true, changeYear: true, dateFormat: "yy-mm-dd", showButtonPanel: true });
$("#wr_content").addClass("form-control input-sm write-content");
});
</script>
답변에 대한 댓글 2개
2023-06-25 (일) 15:59:47
2023-06-25 (일) 16:05:45
리스트에서는 <?php echo $list[$i]['wr_10'] ?> 하면 나올겁니다.
답변에 대한 댓글 4개
2023-06-25 (일) 16:15:31
아..너무 감사합니다. 출력 잘 됩니다.
마지막으로 목록에서 날짜가 2023-06-26 00:00:00 처럼 나오는데요.. 뒤에 00:00:00 시간 부분을 잘라내고 싶어요...
마지막으로 목록에서 날짜가 2023-06-26 00:00:00 처럼 나오는데요.. 뒤에 00:00:00 시간 부분을 잘라내고 싶어요...
2023-06-25 (일) 16:28:08
[code]<?php echo date("y-m-d", strtotime($list[$i]['wr_10'])) ?>[/code]
이렇게 해 보세요.
이렇게 해 보세요.
2023-06-25 (일) 16:37:18
너무 완벽합니다. 구글링 해 보니
<?php echo mb_substr($list[$i]['wr_10'],0,10); ?> 이런 것도 있길래 적용해 보니 동일한 데이터가 출력 됩니다.
오늘 너무 감사했습니다.
<?php echo mb_substr($list[$i]['wr_10'],0,10); ?> 이런 것도 있길래 적용해 보니 동일한 데이터가 출력 됩니다.
오늘 너무 감사했습니다.
2023-06-25 (일) 16:41:59
네 수고 하셨습니다.
mb_substr 은 글자를 자르는 함수 입니다. 날짜포맷 함수를 사용 하세요.
mb_substr 은 글자를 자르는 함수 입니다. 날짜포맷 함수를 사용 하세요.
답변을 작성하려면 로그인이 필요합니다.
리스트와 목록에서 <?php echo ($view['wr_10']); ?> 처럼 불러 오면 되는지요??