Print days of the week in php
I want to get Monday, Tuesday, Wednesday... using php function. Show I have only numeric values for those like 1,2,3..7 where 1 = Monday 2 = Tuesday ... 7 = Sunday. Can anybody help me regarding this. Thanks, Kanji asked Dec 29, 2010 at 6:07 6 My personal favorite...
Khantahr 7,9084 gold badges33 silver badges55 bronze badges answered Dec 8, 2012 at 19:21
CarlosCarlos 1601 gold badge2 silver badges13 bronze badges If all you have is a numeric value and not a complete timestamp, by far the easiest way is this:
answered Dec 29, 2010 at 6:14
deceze♦deceze 497k81 gold badges718 silver badges865 bronze badges DateTime::format, with the Object Oriented style:
Procedural style:
You can create a DateTime object with DateTime::__construct, and you can learn more about DateTime formats here. answered Dec 29, 2010 at 6:12
waiwai933waiwai933 13.7k21 gold badges62 silver badges84 bronze badges 3 The following should give you the day of the week for today (ex. tuesday): or for a specific date you can use something like this: For more info: http://www.php.net/manual/en/function.date.php If you have just a number that you are trying to convert to a day of the week, you could use the following:
answered Dec 29, 2010 at 6:28
Andy FlemingAndy Fleming 7,3945 gold badges32 silver badges53 bronze badges
So you can create a simple function like this:
Demo: http://www.ideone.com/hrITc answered Dec 29, 2010 at 6:29
karim79karim79 336k66 gold badges410 silver badges405 bronze badges If you simply want to convert 0 to "Monday", 1 to "Tuesday", etc. use an array.
answered Dec 29, 2010 at 6:46
Amil WaduwawaraAmil Waduwawara 1,6121 gold badge16 silver badges14 bronze badges 1
answered Dec 29, 2010 at 6:15
rajmohanrajmohan 1,5981 gold badge13 silver badges32 bronze badges How do I print the day of the week in PHP?Use strtotime() function to get the first day of week using PHP. This function returns the default time variable timestamp and then use date() function to convert timestamp date into understandable date. strtotime() Function: The strtotime() function returns the result in timestamp by parsing the time string.
What is date() in php?In PHP, the date() function is used for formatting the date and time. The date() function also formats a timestamp. A timestamp is a sequence of characters, denoting the date and/or time at which a certain event occurred. A timestamp is the number of seconds from January 1, 1970 at 00:00.
How can I get first day of next week in PHP?How to get first day of week in PHP?. Example. Live Demo.. Output. This will produce the following output − First day = Monday - 09/12/2019.. Example. Let us now see another example −. Output. This will produce the following output − Displaying Sunday as first day of a week... First day (next week) = Sunday - 15/12/2019.. How can I tell if PHP is today is Monday?This should solve it: $day = date('D'); $date = date('d') if($day == Mon){ //Code for monday } if($date == 01){ //code for 1st fo the month } else{ //not the first, no money for you =/ }
|