Hướng dẫn date from string php
Sử dụng Lưu ý: Có sự khác biệt giữa việc sử dụng dấu gạch chéo lên Quan sát sự khác biệt giữa định dạng m / d / Y và mdY. PHP xem xét https://stackoverflow.com/questions/6238992/converting-string-to-date-and-datetime View Discussion Improve Article Save Article View Discussion Improve Article Save Article Converting the string to Date and DateTime
uses several functions/methods like strtotime(), getDate(). We will see what these functions do. Parameter
Return Type Returns the number of seconds passed since Jan 1, 1970. getDate() This function return the date/time information of the passed parameter(date/time); getDate(parameter); Parameter The parameter is optional as it takes the current local time as default parameter. Code for converting a string to date
Output: Array ( [seconds] => 0 [minutes] => 0 [hours] => 0 [mday] => 21 [wday] => 6 [mon] => 5 [year] => 2011 [yday] => 140 [weekday] => Saturday [month] => May [0] => 1305936000 ) Code for converting a string to dateTime
Output: 10/Jun/2011 07:00:02 Note1 We can use “D” in the place of “d” for getting the day in the output
Output: Tue/May/2011 03:00:02 Note 2 We can use “H” in the place of “h” for getting the time in 24 Hour format in the output
Output: Tue/May/2011 15:00:02 Similarly, the “i” and “s” could also be changed to uppercase to find different outputs, it is possible but not of much use. PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples. giải pháp 1.Sử dụng
Lưu ý: Có sự khác biệt giữa việc sử dụng dấu gạch chéo lên giải pháp 2Quan sát sự khác biệt giữa định dạng m / d / Y và mdY. PHP xem xét
https://stackoverflow.com/questions/6238992/converting-string-to-date-and-datetime |