Get the App
SLTechnology News&Howtos  ›  Development  › 

How to transfer date by php sql string

Shulou Source: shulou.com Published: 2022-06-02 14:53:40 09月27日 Update

This article mainly explains "how to convert php sql string to date". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to convert php sql string to date".

Php sql string to date conversion method: 1, through "date (" Y-m-d ", strtotime ("));" way conversion; 2, through "date (" M-d-Y ", mktime);" way conversion.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

How does the php sql string change the date?

Two ways for php to convert a string into date and store it in a database

The first way

The code is as follows:

$date= date ("Y-m-d", strtotime ("2011-12-12"))

The second way

The code is as follows:

$date = "2011-12-12"; $year= ((int) substr ($date,0,4)); / / get the year $month= ((int) substr ($date,5,2)); / / get the month $day= ((int) substr ($date,8,2)); / / get the number $_ date = date ("M-d-Y", mktime) At this point, I believe you have a deeper understanding of "php sql string how to change the date", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Characters strings dates methods codes contents methods learning practical deeper interest practicality actual year easy to operate data database more months friends Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information Apple Shulou Technology MariaDB