• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:27
CEST 10:27
KST 17:27
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL20] Ro24 Preview Pt2: Take-Off7[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18
Community News
Weekly Cups (Aug 18-24): herO dethrones MaxPax6Maestros of The Game—$20k event w/ live finals in Paris30Weekly Cups (Aug 11-17): MaxPax triples again!13Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195
StarCraft 2
General
Weekly Cups (Aug 18-24): herO dethrones MaxPax A Eulogy for the Six Pool Geoff 'iNcontroL' Robinson has passed away 2v2 & SC: Evo Complete: Weekend Double Feature The GOAT ranking of GOAT rankings
Tourneys
WardiTV Mondays Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament Monday Nights Weeklies
Strategy
Custom Maps
External Content
Mutation # 488 What Goes Around Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below
Brood War
General
Joined effort [ASL20] Ro24 Preview Pt2: Take-Off No Rain in ASL20? BW General Discussion Flash On His 2010 "God" Form, Mind Games, vs JD
Tourneys
[ASL20] Ro24 Group F [ASL20] Ro24 Group E [Megathread] Daily Proleagues [IPSL] CSLAN Review and CSLPRO Reimagined!
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
General RTS Discussion Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine US Politics Mega-thread The year 2050 European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
High temperatures on bridge(s) Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment"
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
Evil Gacha Games and the…
ffswowsucks
Breaking the Meta: Non-Stand…
TrAiDoS
INDEPENDIENTE LA CTM
XenOsky
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1919 users

PHP - Date Format Check - Page 2

Blogs > tofucake
Post a Reply
Prev 1 2 All
Dycedarg
Profile Joined July 2010
United States12 Posts
July 23 2010 18:28 GMT
#21
The database doesn't follow a standard date format? That just sounds horrible...
tofucake
Profile Blog Joined October 2009
Hyrule19077 Posts
July 23 2010 20:09 GMT
#22
Yeah. "Date" fields are all varchar(12)'s.
Liquipediaasante sana squash banana
Pryce
Profile Joined February 2009
Canada7 Posts
Last Edited: 2010-07-24 05:08:38
July 24 2010 05:03 GMT
#23
On July 24 2010 03:19 tofucake wrote:
Because there are already thousands upon thousands of dates in the database. I didn't write the original site, I've come in to fix it.


You should fix the dates in the database, and change the schema to use the SQL date type for columns that are meant to store dates. The database will then constrain your inputs and outputs to be sane values (which may require some input validation logic). After that's in place, you can throw the date fixing script away, as that's the type of code that shouldn't live in production code. You'll have a hell of a time unit testing it.
Count9
Profile Blog Joined May 2009
China10928 Posts
Last Edited: 2010-07-24 06:30:14
July 24 2010 06:24 GMT
#24
I just add a MM/DD/YYYY thing next to every date entry box and write one regex to check if it's valid, just seems to make more sense.

Oh, it's already in the database LOL, that sucks. Though I'm sure there's already a date parser somewhere.

Also,
// for unknown d-m order assume month is first
is really sketchy >.>

Also also, it's generally better to just parse the date with regex then use another process to check whether the date is valid (e.g. not 99-99-9999) cause it's not very efficient to use so many alternations, which makes the regex engine backtrack quite a bit.
Cambium
Profile Blog Joined June 2004
United States16368 Posts
July 24 2010 06:35 GMT
#25
On July 24 2010 14:03 Pryce wrote:
Show nested quote +
On July 24 2010 03:19 tofucake wrote:
Because there are already thousands upon thousands of dates in the database. I didn't write the original site, I've come in to fix it.


You should fix the dates in the database, and change the schema to use the SQL date type for columns that are meant to store dates. The database will then constrain your inputs and outputs to be sane values (which may require some input validation logic). After that's in place, you can throw the date fixing script away, as that's the type of code that shouldn't live in production code. You'll have a hell of a time unit testing it.


Agreed completely, especially the production code point; this piece of code will be a nightmare to maintain down the road. I'd put the check at the php level or even JS level instead of relying on the db to throw exceptions.

The whole thing just seems completely unnecessary. After all, user stupidity is unbound, and you can't check for everything.
When you want something, all the universe conspires in helping you to achieve it.
tofucake
Profile Blog Joined October 2009
Hyrule19077 Posts
July 24 2010 12:41 GMT
#26
I have the date check function because my current assignment is to fix a particular page. Once that's done I'll have a new assignment, and I'm going to be pushing for that to be to fix some things in the database (like dates! but there are bigger problems), and then move the check from being used tens of thousands of times in processing to once to validate input before it's stored.
Liquipediaasante sana squash banana
Prev 1 2 All
Please log in or register to reply.
Live Events Refresh
Next event in 1h 33m
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Sea 2607
Horang2 1924
Stork 471
Larva 247
Tasteless 228
Pusan 219
Backho 195
ggaemo 174
Nal_rA 150
PianO 127
[ Show more ]
Soulkey 73
soO 54
TY 51
ToSsGirL 46
Sacsri 19
Sharp 12
ivOry 5
Dota 2
Fuzer 134
XcaliburYe77
NeuroSwarm75
BananaSlamJamma53
XaKoH 40
Counter-Strike
Stewie2K424
Other Games
summit1g8201
singsing1040
ceh9536
WinterStarcraft442
SortOf154
Happy148
trigger7
Organizations
Other Games
gamesdonequick594
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH345
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo686
• Stunt674
• Jankos541
Upcoming Events
Afreeca Starleague
1h 33m
hero vs Alone
Royal vs Barracks
Replay Cast
15h 33m
The PondCast
1d 1h
WardiTV Summer Champion…
1d 2h
Clem vs Classic
herO vs MaxPax
Replay Cast
1d 15h
LiuLi Cup
2 days
MaxPax vs TriGGeR
ByuN vs herO
Cure vs Rogue
Classic vs HeRoMaRinE
Cosmonarchy
2 days
OyAji vs Sziky
Sziky vs WolFix
WolFix vs OyAji
BSL Team Wars
2 days
Team Hawk vs Team Dewalt
BSL Team Wars
2 days
Team Hawk vs Team Bonyth
SC Evo League
3 days
TaeJa vs Cure
Rogue vs threepoint
ByuN vs Creator
MaNa vs Classic
[ Show More ]
Maestros of the Game
3 days
ShoWTimE vs Cham
GuMiho vs Ryung
Zoun vs Spirit
Rogue vs MaNa
[BSL 2025] Weekly
3 days
SC Evo League
4 days
Maestros of the Game
4 days
SHIN vs Creator
Astrea vs Lambo
Bunny vs SKillous
HeRoMaRinE vs TriGGeR
BSL Team Wars
4 days
Team Bonyth vs Team Sziky
BSL Team Wars
4 days
Team Dewalt vs Team Sziky
Monday Night Weeklies
5 days
Replay Cast
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

CSLAN 3
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
Acropolis #4 - TS1
CSL Season 18: Qualifier 2
SEL Season 2 Championship
WardiTV Summer 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
Sisters' Call Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.