当前位置:网站首页>How does MySQL convert stored seconds into dates
How does MySQL convert stored seconds into dates
2022-04-23 06:05:00 【fusheng-fate】
The type of date the database stores
There are many ways to store time in a database , For different considerations, storage methods are also different , Several common types are :timestamp,int( Number of seconds ),bigint( Number of milliseconds ),date( Specific date ),time( when 、 branch 、 second ).
When the time stored in the database is seconds or milliseconds , How to convert it to a specific date , Can pass FROM_UNIXTIME(sec,format) Functions and UNIX_TIMESTAMP(date) The function implements seconds / Conversion of milliseconds and date .
FROM_UNIXTIME(sec,format)
- The function converts seconds to dates
- Parameters sec It refers to the number of seconds ,format Refers to the format
select FROM_UNIXTIME(u_registryDate,'%Y-%m-%d %h:%i:%s') from u_user
UNIX_TIMESTAMP(date)
- Convert date to seconds
- date It's the date
select UNIX_TIMESTAMP(date) from u_user
SEC_TO_TIME(sec)
- Convert seconds to hours : minute : Second form
select SEC_TO_TIME(u_registryDate) from u_user
TIME_TO_SEC(date)
- Convert time to seconds ,date Format X when X branch X second , If it is in the format of hour, minute and second of month, year and day, only turn the following hour, minute and second
select TIME_TO_SEC(date) from u_user
attach
Date common operation specifier :
| specifier | explain |
|---|---|
| %a | The abbreviated name of a weekday (Sun~Sat) |
| %b | Abbreviated name of the month (Jan…Dec) |
| %c | month , Digital form (0~12) |
| %D | Date of the month with English suffix (0th, 2st, 3nd,…) |
| %d | Date of the month , Digital form (00~31) |
| %e | Date of the month , Digital form ((0~31) |
| %f | Microsecond (000000 …999999) |
| %H | With 2 Digit representation 24 Hours (00~23) |
| %h, %I | With 2 Digit representation 12 Hours (01~12) |
| %i | minute , Digital form (00~59) |
| %j | — Days of the year (001~366) |
| %k | With 24 Hours (0~23) Express |
| %l | With 12 Hours (1~12) Express |
| %M | The name of the month (January~December) |
| %m | month , Digital form (00~12) |
| %p | In the morning (AM) Or afternoon (PM) |
| %r | Time ,12 hourly ( Hours (hh): minute (mm) : Number of seconds (ss) After add AM or PM) |
| %S, %s | With 2 The number of digits represents seconds (00~59) |
| %T | Time ,24 hourly ( Hours (hh): minute (mm): Number of seconds (ss)) |
| %U | Zhou (00~53), Sunday is the first day of the week |
| %u | Zhou (00~53), Monday is the first day of the week |
| %V | Zhou (01~53), Sunday is the first day of the week , and %X Use at the same time |
| %v | Zhou (01~53), Monday is the first day of the week , and %x Use at the same time |
| %W | Week logo ( Sunday 、 Monday 、 Tuesday … Saturday ) |
| %w | — Every day of the week (0= Sunday …6= Saturday ) |
| %X | The year of the week , Sunday is the first day of the week , Digital form ,4 digit , and %V Use at the same time |
| %x | The year of the week , Monday is the first day of the week , Digital form ,4 digit , and %v Use at the same time |
| %Y | 4 The number of digits represents the year |
| %y | 2 The number of digits represents the year |
| %% | % A literal character |
版权声明
本文为[fusheng-fate]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230539253349.html
边栏推荐
- 数据处理之Numpy常用函数表格整理
- Graphic numpy array matrix
- 图像恢复论文简记——Uformer: A General U-Shaped Transformer for Image Restoration
- Complete example demonstration of creating table to page - joint table query
- Exception handling: grab and throw model
- Kingdee EAS "general ledger" system calls "de posting" button
- 深入源码分析Servlet第一个程序
- PyQt5学习(一):布局管理+信号和槽关联+菜单栏与工具栏+打包资源包
- Pyqy5 learning (2): qmainwindow + QWidget + qlabel
- Pytorch learning record (IV): parameter initialization
猜你喜欢

给yarn配置国内镜像加速器

深入源码分析Servlet第一个程序

Pyqy5 learning (2): qmainwindow + QWidget + qlabel

Fundamentals of digital image processing (Gonzalez) I

On traversal of binary tree

深入理解去噪论文——FFDNet和CBDNet中noise level与噪声方差之间的关系探索

Implementation of displaying database pictures to browser tables based on thymeleaf

PyEMD安装及简单使用

In depth source code analysis servlet first program
![如何利用对比学习做无监督——[CVPR22]Deraining&[ECCV20]Image Translation](/img/33/780b80693f70112eebc10941f7c134.png)
如何利用对比学习做无监督——[CVPR22]Deraining&[ECCV20]Image Translation
随机推荐
Treatment of tensorflow sequelae - simple example record torch utils. data. dataset. Picture dimension problem when rewriting dataset
The user name and password of users in the domain accessing the samba server outside the domain are wrong
JSP语法及JSTL标签
Multithreading and high concurrency (1) -- basic knowledge of threads (implementation, common methods, state)
PyEMD安装及简单使用
开发环境 EAS登录 license 许可修改
Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi
自动控制(韩敏版)
Pytoch -- data loading and processing
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention
What is the difference between the basic feasible solution and the basic feasible solution in linear programming?
Complete example demonstration of creating table to page - joint table query
DBCP usage
Traitement des séquelles du flux de Tensor - exemple simple d'enregistrement de torche. Utils. Données. Dataset. Problème de dimension de l'image lors de la réécriture de l'ensemble de données
无监督去噪——[TMI2022]ISCL: Interdependent Self-Cooperative Learning for Unpaired Image Denoising
Ptorch learning record (XIII): recurrent neural network
Pytorch学习记录(五):反向传播+基于梯度的优化器(SGD,Adagrad,RMSporp,Adam)
PyQy5学习(二):QMainWindow+QWidget+QLabel
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
Solve the error: importerror: iprogress not found Please update jupyter and ipywidgets