# แปลง Unix Timestamp

> แปลง UNIX Timestamp เป็นวันที่และเวลา และแปลงกลับ แสดง Timestamp ปัจจุบันแบบเรียลไทม์, เวลาท้องถิ่น, UTC และเวลาสัมพัทธ์ ใช้งานฟรีทั้งหมด

URL: https://acrafto.com/th/unix-timestamp-converter/

Tools are interactive browser apps; there is no public API, no endpoints to call and no server-side processing. To use a tool, open its HTML page in a browser.

## เครื่องมือแปลง UNIX Timestamp (ตัวแปลงเวลา UNIX ออนไลน์)

**เครื่องมือแปลง UNIX Timestamp** นี้ช่วยให้คุณสามารถแปลง **เวลา UNIX (epoch time / POSIX time)** เป็น **วันที่และเวลา** และแปลงกลับได้อย่างรวดเร็ว รองรับ **Timestamp ทั้งแบบวินาทีและมิลลิวินาที** แสดงผล **เวลาท้องถิ่น**, **UTC** และ **ISO 8601** และสามารถ **คัดลอก** ผลลัพธ์ได้ด้วยการคลิกเพียงครั้งเดียว

---

## UNIX Timestamp (epoch time / POSIX time) คืออะไร?

**UNIX Timestamp** คือตัวเลขที่แสดงเวลาเป็น **จำนวนวินาทีที่ผ่านไปนับตั้งแต่วันที่ 1 มกราคม 1970 เวลา 00:00:00 UTC** (เรียกว่า **UNIX epoch**) ในทางปฏิบัติ เป็นหนึ่งในรูปแบบที่ใช้บ่อยที่สุดสำหรับการจัดเก็บและส่งผ่านข้อมูลวันที่และเวลาในระบบ, ฐานข้อมูล, API และการบันทึกข้อมูล

**ตัวอย่าง:** `1700000000` ตรงกับวันที่ **14 พฤศจิกายน 2023 เวลา 22:13:20 UTC**

### ทำไมต้องเป็นวันที่ 1 มกราคม 1970?

จุดเริ่มต้นของยุค (1970-01-01) ถูกเลือกเมื่อมีการออกแบบ UNIX เพื่อเป็นจุดอ้างอิงที่ใช้งานได้จริง: ใกล้เคียงกับช่วงเวลาที่ระบบถูกสร้างขึ้น และช่วยให้การคำนวณเวลาง่ายขึ้น

---

## UNIX Timestamp ในหน่วยวินาที vs. มิลลิวินาที

UNIX Timestamp มักจะปรากฏในสองรูปแบบหลัก:

| รูปแบบ Timestamp | ตัวอย่าง | การใช้งานทั่วไป |
| --- | ---: | --- |
| **วินาที (s)** | 1700000000 | ฐานข้อมูล, แบ็กเอนด์, API, ไฟล์ |
| **มิลลิวินาที (ms)** | 1700000000000 | JavaScript (Date.now()), การวิเคราะห์, บันทึกรายละเอียด |

**วิธีสังเกตว่าคุณมีรูปแบบใด?**

- **วินาที** สำหรับข้อมูล “ปัจจุบัน” มักจะมี **10 หลัก**
- **มิลลิวินาที** มักจะมี **13 หลัก** และมีค่าประมาณ **1000 เท่า**
- โดยประมาณ: หากค่า **\> 10¹²** เกือบจะแน่นอนว่าเป็น **มิลลิวินาที**

---

## วิธีใช้เครื่องมือแปลง UNIX Timestamp

### 1) Timestamp → วันที่และเวลา

1. ป้อน **UNIX Timestamp** ลงในช่อง หรือคลิกที่ **ตอนนี้** (เวลา UNIX ปัจจุบัน)
2. หาก Timestamp อยู่ในหน่วย **มิลลิวินาที** ให้เปิดใช้งานตัวเลือก **มิลลิวินาที**
3. คลิกที่ **แปลง** (หรือกด Enter)
4. ผลลัพธ์การแปลงจะแสดงเป็น **เวลาท้องถิ่น**, **UTC** และ **ISO 8601**
5. คลิกที่ผลลัพธ์เพื่อ **คัดลอกไปยังคลิปบอร์ด**

### 2) วันที่และเวลา → Timestamp

1. เลือก **วันที่และเวลา** ในแบบฟอร์ม
2. คลิกที่ **แปลง**
3. คุณจะได้รับผลลัพธ์เป็น **Timestamp ทั้งในหน่วยวินาทีและมิลลิวินาที**

---

## UNIX Timestamp ถูกใช้บ่อยที่สุดที่ไหน?

คุณจะพบเวลา UNIX ได้แทบทุกที่ที่มีการทำงานกับเวลาในด้าน IT:

- **ฐานข้อมูล** – การจัดเก็บและเปรียบเทียบเวลาใน MySQL, PostgreSQL, SQLite และอื่นๆ
- **API** – REST/GraphQL มักจะคืนค่าเวลาเป็น Timestamp (ง่ายต่อการจัดรูปแบบ)
- **บันทึก (Logs) และการเฝ้าระวัง** – การจัดเรียงเหตุการณ์ตามเวลาอย่างแม่นยำ
- **Git** – การคอมมิทมีข้อมูลเวลา
- **ระบบไฟล์** – เวลาเช่น mtime/ctime/atime (การแก้ไขล่าสุด เป็นต้น)
- **JWT** – claim `iat` (เวลาที่ออก) และ `exp` (เวลาหมดอายุ) มักจะอยู่ในรูปแบบ epoch seconds
- **Linux/Unix shell** – `date +%s` คืนค่า Timestamp ปัจจุบัน
- **JavaScript** – `Date.now()` คืนค่าเวลาในหน่วย **มิลลิวินาที**

---

## ตัวอย่างการแปลงเวลา UNIX ในทางปฏิบัติ

### JavaScript (timestamp ↔ วันที่)

```
// UNIX Timestamp ปัจจุบันในหน่วยวินาที
const tsSeconds = Math.floor(Date.now() / 1000);

// Timestamp ปัจจุบันในหน่วยมิลลิวินาที
const tsMs = Date.now();

// Timestamp (s) -> วันที่
const dateFromSeconds = new Date(1700000000 * 1000);
console.log(dateFromSeconds.toISOString());

// วันที่ -> Timestamp (s)
const ts = Math.floor(new Date("2024-01-01T00:00:00Z").getTime() / 1000);
console.log(ts);
```

### Python (timestamp ↔ datetime)

```
import time
from datetime import datetime, timezone

# Timestamp ปัจจุบันในหน่วยวินาที
ts = int(time.time())

# Timestamp -> datetime (UTC)
dt_utc = datetime.fromtimestamp(1700000000, tz=timezone.utc);

# วันที่ -> Timestamp
ts2 = int(datetime(2024, 1, 1, tzinfo=timezone.utc).timestamp());
```

### SQL (MySQL)

```
-- UNIX Timestamp ปัจจุบัน (s)
SELECT UNIX_TIMESTAMP();

-- Timestamp -> วันที่
SELECT FROM_UNIXTIME(1700000000);

-- วันที่ -> Timestamp
SELECT UNIX_TIMESTAMP('2024-01-01 00:00:00');
```

---

## เขตเวลา: UTC, เวลาท้องถิ่น และ ISO 8601

**UNIX Timestamp อยู่ในรูปแบบ UTC เสมอ** – ไม่รวมข้อมูลเขตเวลาหรือเวลาออมแสง การแปลงเป็นเวลาท้องถิ่นขึ้นอยู่กับการตั้งค่าของเบราว์เซอร์, เซิร์ฟเวอร์ หรือไลบรารีที่ใช้

แนวคิดที่คุณควรรู้:

- **UTC** – มาตรฐานสากลที่ไม่มีเวลาออมแสง
- **GMT** – ในการใช้งานทั่วไป แทบจะเหมือนกับ UTC
- **Offset** – ค่าชดเชยจาก UTC (เช่น กรุงเทพฯ **UTC+7**)

---

## ข้อจำกัดของ UNIX Timestamp และปัญหาปี 2038

### ปัญหาปี 2038 (Year 2038 Problem)

ในบาง **ระบบ 32 บิต** Timestamp จะถูกจัดเก็บเป็น `int32` โดยมีค่าสูงสุดที่ **2,147,483,647** ซึ่งตรงกับ **วันที่ 19 มกราคม 2038 เวลา 03:14:07 UTC** หลังจากการเกินขีดจำกัดนี้ อาจเกิดปัญหา overflow และเวลาที่ไม่ถูกต้องได้ ระบบ **64 บิต** ที่ทันสมัยมักจะไม่มีปัญหานี้

### ช่วงเวลาของ UNIX Time แบบ 64 บิต

ค่า 64 บิตครอบคลุมช่วงเวลาที่กว้างมาก (ในทางปฏิบัติคือ “ตลอดไป”) ค่าลบหมายถึงวันที่ **ก่อนวันที่ 1 มกราคม 1970**

---

## คำถามที่พบบ่อย – เกี่ยวกับ UNIX Timestamp

### UNIX Timestamp อยู่ในรูปแบบ UTC หรือเวลาท้องถิ่น?

UNIX Timestamp อยู่ในรูปแบบ **UTC** เสมอ เวลาท้องถิ่นจะเกิดขึ้นเมื่อมีการแปลงตามเขตเวลา เครื่องมือแปลงจึงมักจะแสดงทั้งเวลา UTC และเวลาท้องถิ่น

### จะรู้ได้อย่างไรว่า Timestamp อยู่ในหน่วยวินาทีหรือมิลลิวินาที?

สำหรับช่วงเวลาปัจจุบัน Timestamp ในหน่วย **วินาที** โดยทั่วไปจะมี **10 หลัก** ในขณะที่ **มิลลิวินาที** มักจะมี **13 หลัก** และมีค่ามากกว่าประมาณ **1000 เท่า** โดยประมาณ: หากค่า **\> 10¹²** มักจะเป็นมิลลิวินาที

### UNIX Timestamp ค่าลบหมายถึงอะไร?

Timestamp ค่าลบแสดงถึงวันที่ **ก่อนวันที่ 1 มกราคม 1970** ตัวอย่างเช่น `-1` ตรงกับ **31 ธันวาคม 1969 เวลา 23:59:59 UTC**

### จะแปลง UNIX Timestamp ใน SQL ได้อย่างไร?

ใน MySQL คุณจะใช้ `FROM_UNIXTIME(timestamp)` และแปลงกลับด้วย `UNIX_TIMESTAMP(date)` ใน PostgreSQL มักจะเป็น `TO_TIMESTAMP(timestamp)` และ `EXTRACT(EPOCH FROM date)`

### ทำไม UNIX epoch ถึงเริ่มต้นที่ 1 มกราคม 1970?

นี่เป็นจุดอ้างอิงที่ถูกเลือกทางประวัติศาสตร์ตั้งแต่ยุคแรกของ UNIX: เรียบง่าย ใช้งานได้จริง และใกล้เคียงกับช่วงเวลาที่ระบบถูกพัฒนาขึ้น

## Other languages

- Čeština (cs): [Unix timestamp převodník](https://acrafto.com/cs/unix-timestamp/) ([Markdown](https://acrafto.com/cs/unix-timestamp/index.md))
- Slovenčina (sk): [Unix timestamp konvertor](https://acrafto.com/sk/unix-timestamp-prevodnik/) ([Markdown](https://acrafto.com/sk/unix-timestamp-prevodnik/index.md))
- English (en): [UNIX Timestamp Converter](https://acrafto.com/en/unix-timestamp-converter/) ([Markdown](https://acrafto.com/en/unix-timestamp-converter/index.md))
- Deutsch (de): [Unix Timestamp umrechnen](https://acrafto.com/de/unix-timestamp-konverter/) ([Markdown](https://acrafto.com/de/unix-timestamp-konverter/index.md))
- Français (fr): [Convertisseur timestamp Unix](https://acrafto.com/fr/convertisseur-timestamp-unix/) ([Markdown](https://acrafto.com/fr/convertisseur-timestamp-unix/index.md))
- Español (es): [Convertidor de UNIX timestamp](https://acrafto.com/es/convertidor-timestamp-unix/) ([Markdown](https://acrafto.com/es/convertidor-timestamp-unix/index.md))
- Italiano (it): [Convertitore timestamp UNIX](https://acrafto.com/it/convertitore-timestamp-unix/) ([Markdown](https://acrafto.com/it/convertitore-timestamp-unix/index.md))
- Português (pt): [Conversor de timestamp Unix](https://acrafto.com/pt/conversor-timestamp-unix/) ([Markdown](https://acrafto.com/pt/conversor-timestamp-unix/index.md))
- Nederlands (nl): [Unix timestamp converter](https://acrafto.com/nl/unix-timestamp-converter/) ([Markdown](https://acrafto.com/nl/unix-timestamp-converter/index.md))
- Polski (pl): [Konwerter UNIX timestamp](https://acrafto.com/pl/konwerter-unix-timestamp/) ([Markdown](https://acrafto.com/pl/konwerter-unix-timestamp/index.md))
- Română (ro): [Convertor Unix timestamp](https://acrafto.com/ro/convertor-unix-timestamp/) ([Markdown](https://acrafto.com/ro/convertor-unix-timestamp/index.md))
- Magyar (hu): [UNIX időbélyeg konvertáló](https://acrafto.com/hu/unix-idobelyeg-atalakito/) ([Markdown](https://acrafto.com/hu/unix-idobelyeg-atalakito/index.md))
- Ελληνικά (el): [Μετατροπέας Unix timestamp](https://acrafto.com/el/unix-timestamp-converter/) ([Markdown](https://acrafto.com/el/unix-timestamp-converter/index.md))
- Български (bg): [Unix timestamp конвертор](https://acrafto.com/bg/unix-timestamp-konverter/) ([Markdown](https://acrafto.com/bg/unix-timestamp-konverter/index.md))
- Hrvatski (hr): [Unix timestamp konverter](https://acrafto.com/hr/unix-timestamp-konverter/) ([Markdown](https://acrafto.com/hr/unix-timestamp-konverter/index.md))
- Slovenščina (sl): [Pretvornik Unix timestamp](https://acrafto.com/sl/unix-timestamp-pretvornik/) ([Markdown](https://acrafto.com/sl/unix-timestamp-pretvornik/index.md))
- Eesti (et): [UNIX timestamp teisendaja](https://acrafto.com/et/unix-timestamp-teisendaja/) ([Markdown](https://acrafto.com/et/unix-timestamp-teisendaja/index.md))
- Latviešu (lv): [UNIX laika zīmogu pārveidotājs](https://acrafto.com/lv/unix-timestamp-konvertetajs/) ([Markdown](https://acrafto.com/lv/unix-timestamp-konvertetajs/index.md))
- Lietuvių (lt): [UNIX laiko žymės keitiklis](https://acrafto.com/lt/unix-laiko-zymes-keitiklis/) ([Markdown](https://acrafto.com/lt/unix-laiko-zymes-keitiklis/index.md))
- Svenska (sv): [Unix timestamp-omvandlare](https://acrafto.com/sv/unix-timestamp-omvandlare/) ([Markdown](https://acrafto.com/sv/unix-timestamp-omvandlare/index.md))
- Dansk (da): [UNIX timestamp konverter](https://acrafto.com/da/unix-timestamp-konverter/) ([Markdown](https://acrafto.com/da/unix-timestamp-konverter/index.md))
- Suomi (fi): [UNIX-aikaleiman muunnin](https://acrafto.com/fi/unix-aikaleiman-muunnin/) ([Markdown](https://acrafto.com/fi/unix-aikaleiman-muunnin/index.md))
- Norsk (no): [Unix timestamp-konverterer](https://acrafto.com/no/unix-tidsstempel-konverterer/) ([Markdown](https://acrafto.com/no/unix-tidsstempel-konverterer/index.md))
- Українська (uk): [Конвертер Unix timestamp](https://acrafto.com/uk/konverter-unix-chasu/) ([Markdown](https://acrafto.com/uk/konverter-unix-chasu/index.md))
- Русский (ru): [Unix timestamp конвертер](https://acrafto.com/ru/unix-timestamp-konverter/) ([Markdown](https://acrafto.com/ru/unix-timestamp-konverter/index.md))
- Српски (sr): [UNIX timestamp konverter](https://acrafto.com/sr/unix-timestamp-konverter/) ([Markdown](https://acrafto.com/sr/unix-timestamp-konverter/index.md))
- Македонски (mk): [UNIX timestamp конвертор](https://acrafto.com/mk/unix-timestamp-konvertor/) ([Markdown](https://acrafto.com/mk/unix-timestamp-konvertor/index.md))
- Bosanski (bs): [Unix timestamp konverter](https://acrafto.com/bs/unix-timestamp-konverter/) ([Markdown](https://acrafto.com/bs/unix-timestamp-konverter/index.md))
- Shqip (sq): [Konvertues Unix timestamp](https://acrafto.com/sq/konvertues-timestamp-unix/) ([Markdown](https://acrafto.com/sq/konvertues-timestamp-unix/index.md))
- Türkçe (tr): [UNIX zaman damgası dönüştürücü](https://acrafto.com/tr/unix-zaman-damgasi-donusturucu/) ([Markdown](https://acrafto.com/tr/unix-zaman-damgasi-donusturucu/index.md))
- 日本語 (ja): [UNIXタイムスタンプ変換](https://acrafto.com/ja/unix-timestamp-converter/) ([Markdown](https://acrafto.com/ja/unix-timestamp-converter/index.md))
- 한국어 (ko): [유닉스 타임스탬프 변환기](https://acrafto.com/ko/unix-timestamp-converter/) ([Markdown](https://acrafto.com/ko/unix-timestamp-converter/index.md))
- العربية (ar): [محول Unix Timestamp](https://acrafto.com/ar/unix-timestamp-converter/) ([Markdown](https://acrafto.com/ar/unix-timestamp-converter/index.md))
- हिन्दी (hi): [UNIX टाइमस्टैम्प कनवर्टर](https://acrafto.com/hi/unix-timestamp-converter/) ([Markdown](https://acrafto.com/hi/unix-timestamp-converter/index.md))
- Bahasa Indonesia (id): [Konverter Unix timestamp](https://acrafto.com/id/konverter-timestamp-unix/) ([Markdown](https://acrafto.com/id/konverter-timestamp-unix/index.md))
- Tiếng Việt (vi): [Chuyển đổi Unix timestamp](https://acrafto.com/vi/bo-chuyen-doi-unix-timestamp/) ([Markdown](https://acrafto.com/vi/bo-chuyen-doi-unix-timestamp/index.md))
- עברית (he): [ממיר Unix Timestamp](https://acrafto.com/he/unix-timestamp-converter/) ([Markdown](https://acrafto.com/he/unix-timestamp-converter/index.md))
