| |

VerySource

 Forgot password?
 Register
Search
View: 669|Reply: 2

How to get formatted datetime value from database

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-3 18:20:01
| Show all posts |Read mode
The time field in the mysql database table is of the datetime type. Use the date () function to obtain the time: $ regtime = date ("Y-m-d H: n: s"). Now I need to display only Y-m-d when outputting. How to format the output?
Reply

Use magic Report

0

Threads

24

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-1-4 06:33:01
| Show all posts
echo date ("Y-m-d", strtotime ($ regtime));
Why not save it as a Unix timestamp?
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-6 06:51:01
| Show all posts
thank you very much. Thanks for reminding, I will use timestamp in the future.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list