• 전화하지 마셈
  • hyungseob@ssim.pe.kr
Codeigniter 3.x에서 4.x로 갈아 엎느라 기존 게시판 주소로 접근시 새 주소로 리다이렉션 된다.

Developerment [Flutter]

타임스탬프 형식을 일반 날짜/시간 형식로 변환해서 출력하기

  • 빛그림
  • 681
웹서버의 데이터를 파싱해서 출력하는 기능을 구현하는 과정중 DB에 유닉스타임 형태로 저장된 값을 날짜/시간 형식으로 변환해서 가져오려고 하다가 다트 언어 내에서 해결하고자 아래와 같은 코드로 처리했다.
 
var format = new DateFormat('y-MM-dd HH:mm');
var regDate = new DateTime.fromMicrosecondsSinceEpoch(int.parse(rows[index]['reg_date']) * 1000);
print(format.format(regDate));

rows[index]['reg_date']은 JSON에서 가져온 데이터 목록의 유닉스타임 값이고, String값이었기 때문에 int로 형변환을 해줬다.

*DateFormat 은 아래 문서를 참고하면 된다.
https://pub.dartlang.org/documentation/intl/latest/intl/DateFormat-class.html

새댓글 등록