"PHP uniqid()"의 두 판 사이의 차이

14번째 줄: 14번째 줄:
echo uniqid('hello_');
echo uniqid('hello_');
# hello_56fdc64b3ea94
# hello_56fdc64b3ea94
</source>
==생성일시 확인==
<source lang='php'>
function uniqid2datetime($uniqid) {
  return date("Y-m-d H:i:s",hexdec(substr($uniqid,0,8)));
}
echo uniqid2datetime('4b3403665fea6');
# 2009-12-25 09:12:22
</source>
</source>



2017년 4월 12일 (수) 10:05 판

1 개요

PHP uniqid()
  • 유니크 ID를 생성하는 PHP 함수[1]
  • 기본은 16진수 13자리
  • 생성일시 정보가 포함되어 있음 (앞 8자리)
그렇기 때문에 반복생성해보면 앞부분은 잘 바뀌지 않음
  • 매개변수를 넣으면 접두어로 붙음
echo uniqid();
# 4b3403665fea6
echo uniqid('hello_');
# hello_56fdc64b3ea94

2 생성일시 확인

function uniqid2datetime($uniqid) {
  return date("Y-m-d H:i:s",hexdec(substr($uniqid,0,8)));
}
echo uniqid2datetime('4b3403665fea6');
# 2009-12-25 09:12:22

3 같이 보기

4 참고 자료

  1. 단, 완벽하게(100%) 유일함을 보장하지는 않음
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}