当前位置:网站首页>mysql时间戳格式转换日期格式字符串
mysql时间戳格式转换日期格式字符串
2022-06-24 15:46:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
1.测试表表结构
CREATE TABLE `timestamp_string_change` (
`id` int NOT NULL AUTO_INCREMENT,
`up_time` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;2. mysql时间戳格式转字符串
方法1 :
select STR_TO_DATE(tsc.up_time, '%Y-%m-%d %H:%i:%s' ) as up_time from timestamp_string_change tsc 方法2:
select from_unixtime(unix_timestamp(up_time), '%Y-%m-%d %H:%i:%s' ) as up_time from timestamp_string_change 注:方法2时,需要先用unix_timestamp()方法将数据转换成时间戳格式,再用from_unixtime()方法将时间戳转换成自定义格式时间字符串。直接用from_unixtime()方法转换出来的数据NULL。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151936.html原文链接:https://javaforall.cn
边栏推荐
- Istio practical skill: hide the automatically added server header
- Introduction to new features of ECMAScript 2019 (ES10)
- Istio practical tips: Customize Max_ body_ size
- The equipment is connected to the easycvr platform through the national standard gb28181. How to solve the problem of disconnection?
- MySQL development specification
- 不忘初心
- great! The novel website project is completely open source
- Paper: Google TPU
- Jenkins 镜像无法更新插件中心的3种解决方法
- 安裝ImageMagick7.1庫以及php的Imagick擴展
猜你喜欢

VNC Viewer方式的远程连接树莓派

Remote connection raspberry pie in VNC Viewer Mode

日志记录真没你想的那么简单

Intelij 中的 Database Tools可以连接但是无法显示SCHEMA, TABLES

Understanding openstack network

Why is it easy for enterprises to fail in implementing WMS warehouse management system

The penetration of 5g users of operators is far slower than that of 4G. The popularity of 5g still depends on China Radio and television

A new weapon to break the memory wall has become a "hot search" in the industry! Persistent memory enables workers to play with massive data + high-dimensional models

Several common DoS attacks

Recommend several super practical data analysis tools
随机推荐
Intelij 中的 Database Tools可以连接但是无法显示SCHEMA, TABLES
Using alicloud RDS for SQL Server Performance insight to optimize database load - first understanding of performance insight
leetcode 139. Word Break 单词拆分(中等)
【附下载】汉化版Awvs安装与简单使用
Detailed explanation of estab of Stata regression table output
使用阿里云RDS for SQL Server性能洞察优化数据库负载-初识性能洞察
great! The novel website project is completely open source
Cap: multiple attention mechanism, interesting fine-grained classification scheme | AAAI 2021
Logging is not as simple as you think
打破内存墙的新利器成行业“热搜”!持久内存让打工人也能玩转海量数据+高维模型
不忘初心
Convert text to hexadecimal, and reverse
2021-04-18: given a two-dimensional array matrix, the value in it is either 1 or 0,
2021-04-22: given many line segments, each line segment has two numbers [start, end],
实现领域驱动设计 - 使用ABP框架 - 领域逻辑 & 应用逻辑
Product level design of a project in SAP mm
Several common DoS attacks
Cap: multiple attention mechanism, interesting fine-grained classification scheme | AAAI 2021
Solution of intelligent all in one machine in expressway service area
Parameterized tests guide in junit5