본문 바로가기

건강한 일상, 전체 글
(473)
자바스크립트 날짜형식 두자리수, 0표시자바스크립트 에서 날짜 나 월을 2자리로 표시하는 방법 날짜 2자리 표시 (“0” + this.getDate()).slice(-2); 월 2자리 표시 (“0” + (this.getMonth() + 1)).slice(-2);
CANNOT USE OBJECT OF TYPE STDCLASS AS ARRAY !! 일때 첫째, 즉 1차는 배열이고 2차는 오브젝트 인 경우 이 에러가 발생한다. 왜? echo 를 배열 출력하듯이 했으니깐…. var_dump로 출력시 Array ( [0] => stdClass Object ( [user_id] => 1531458 [cost] => $10.99 [comment] => hello [tt] => 20110624171220 ) ) 이런 식으로 나온다면 바로 이런 경우. 해결방법1: echo $cart[1]->user_id; 이렇게 echo하면된다. 둘째, json사용시 이런 경우가 발생한다면…. 단순 배열일경우 다음과 같이 반환됨 Array ( [0] => a [1] => b)… 이런 경우는 에러 없는데 문자인덱스배열일 경우에는 다음과 같이 반환됨. stdClass object ([..
사업자 번호 체크 유효성 확인
연습: 1~10까지 배열 생성후 1부터 하나씩 배열에서 빼는 방법 //함수 function arr_del($list_arr, $del_num) // 배열, 삭제할 값 { $key = array_search($del_num, $list_arr); //배열에 키를 알아오고 array_splice($list_arr, $key, 1); // 배열에서 위에서 받아온 키를 삭제 return $list_arr; } //배열생성 $start = 1; $end = 10; for($i=$start;$i
PHP 날짜형식 DATA ATOM 2020-07-03T02:08:40+09:00 php DATE ATOM 날짜형식 T +09:00 형태 $time = new DateTime; echo $time->format(DateTime::ATOM); echo $x = date(DATE_ATOM, mktime(01, 00, 00, 7, 1, 2017)); //2017-07-01T10:20:30+09:00 $today_date = '2009-09-30 20:24:00'; echo '오늘: ' . $today_date; $today_date = date(DATE_ATOM, strtotime($today_date . ' +1 day')); echo '오늘 + 1 day: ' . $today_date; For PHP 5.2.0+, you may also d..
PHP try - catch 문 메뉴얼 http://php.net/manual/en/language.exceptions.php 예제1) if ($step>0) throw new Exception(); 예제2) function inverse($x) { if (!$x) { throw new Exception('Division by zero.'); } return 1/$x; } 예제3) try { print "this is our try block\n"; throw new Exception(); } catch (Exception $e) { print "something went wrong\n"; } finally { print "This part is always executed\n"; } getMessage() getCode()등 설명 h..
CRON 크론 실행을 로그로 저장하여 확인하는 법 CRON 크론 실행을 로그로 저장하여 확인하는 법 crontab -e 01 * * * * lynx --source http://example.com/add.php?pass=1234 >> /var/log/test.log 이렇게 로그를 찍어서 체크할수 있다. crontab -l
MySQL 한글 깨질때 설정방법 [mysqld] collation-server = utf8_unicode_ci init-connect='SET NAMES utf8' character-set-server = utf8