I have a variable that outputs the date in the following format:
201308131830
Which is 2013 - Aug - 13 - 18:30
I am using this to retrieve the day name but it is getting the wrong days:
$dayname = date('D', strtotime($longdate));
Any idea what I am doing wrong?
Go to the Number tab in the Format Cells dialog box. Select Custom as the Category. Add dddd into the Type field for the full weekday name or ddd for the abbreviated weekday name. Press the OK button.
The DAY function takes just one argument, the date from which you want to extract the day. In the example, the formula is: = DAY ( B5 ) B5 contains a date value for January 5, 2016. The DAY function returns the number 5 representing the day...
In a blank cell, please enter the formula =CHOOSE(WEEKDAY(B1),"Sun","Mon","Tue","Wed","Thu","Fri","Sat"), and press the Enter key. This formula will convert the date to the day of week as below screenshot shown.
This is what happens when you store your dates and times in a non-standard format. Working with them become problematic.
$datetime = DateTime::createFromFormat('YmdHi', '201308131830'); echo $datetime->format('D');
See it in action
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With