MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/12jcn8k/how_to_use_dates/
r/badcode • u/TeamRaiderz • Apr 12 '23
7 comments sorted by
22
Image Transcription: Code
"publish_date" => date( "Y-m-d", strtotime( "2023-05-08 00:00:00" ) ), "end_date" => date( "Y-m-d", strtotime( "2023-05-09 00:00:00" ) )
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
4 u/Bleeus Apr 12 '23 Good human
4
Good human
10
Would someone mind explaining please?
26 u/cabbagebot Apr 12 '23 This code appears to parse dates from a hardcoded string just to rewrite them immediately as strings in a different format.Why not just write the date strings into the source code using the intended format? 11 u/iruoy Apr 12 '23 edited Apr 12 '23 take a string ("2023-05-08 00:00:00")convert it to a unix timestamp (1683496800)convert that to a string ("2023-05-08") 1 u/ofnuts Apr 12 '23 Possibly some underlying timezone magic? 6 u/iruoy Apr 12 '23 Both functions will use the same timezone, so nothing will happen.
26
This code appears to parse dates from a hardcoded string just to rewrite them immediately as strings in a different format.
Why not just write the date strings into the source code using the intended format?
11
take a string ("2023-05-08 00:00:00")
"2023-05-08 00:00:00"
convert it to a unix timestamp (1683496800)
1683496800
convert that to a string ("2023-05-08")
"2023-05-08"
1 u/ofnuts Apr 12 '23 Possibly some underlying timezone magic? 6 u/iruoy Apr 12 '23 Both functions will use the same timezone, so nothing will happen.
1
Possibly some underlying timezone magic?
6 u/iruoy Apr 12 '23 Both functions will use the same timezone, so nothing will happen.
6
Both functions will use the same timezone, so nothing will happen.
22
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Apr 12 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
10
u/badapplecider Apr 12 '23
Would someone mind explaining please?