Php formatting time-php Tutorial

Source: Internet
Author: User
Php formatting time. Php5.1.2 and MSSQL links. The time period is smalldatetime. The time shown in the library is: 21:23:00. 000 is displayed in PHP: 2007 & nbsp; April & nbsp; 6 & nbsp;. how can I get a time format like? ------ Solve the php formatting time problem.
Php5.1.2 and MSSQL links.
The time period is smalldatetime.
The time shown in the library is: 21:23:00. 000
It is displayed in PHP: 2007 21:23, January 1, April 6
How can I get a time format like?

------ Solution --------------------
Date ('Y-m-D', strtotime ($ row ['somedate']);
------ Solution --------------------
$ S = "2007-04-06 21:23:00. 000 ";
$ T = explode ("", $ s );
Echo $ t [0];
------ Solution --------------------
$ S = "somedate ";
$ T = explode ("", $ s );

Switch ($ t [1])
Case "January ":
$ Month = "01 ";
Break;
Case "February ":
$ Month = "02 ";
Break;
Case "March ":
$ Month = "03 ";
Break;
Case "April ":
$ Month = "04 ";
Break;
Case "May ":
$ Month = "05 ";
Break;
Case "June ":
$ Month = "06 ";
Break;
Case "July ":
$ Month = "07 ";
Break;
Case "August ":
$ Month = "01 ";
Break;
Case "September ":
$ Month = "09 ";
Break;
Case "October ":
$ Month = 10;
Break;
Case "November ":
$ Month = 11;
Break;
Case "December ":
$ Month = 12;
Break;
}

Echo $ t [0]. "-". $ month. "-". $ t [2];


I am not sure whether the above two methods are correct.

------ Solution --------------------
This is an MSSQL problem. it will call the system time display format.

You can convert strtotime to UNIX timestamp, and then use the date function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.