• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 03:39
CEST 09:39
KST 16:39
  • 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
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Chinese SC2 server to reopen; live all-star event in Hangzhou14Weekly Cups (Oct 13-19): Clem Goes for Four0BSL Team A vs Koreans - Sat-Sun 16:00 CET6Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou RotterdaM "Serral is the GOAT, and it's not close" Weekly Cups (March 17-23): Clem Bounces Back DreamHack Open 2013 revealed The New Patch Killed Mech!
Tourneys
$1,200 WardiTV October (Oct 21st-31st) SC2's Safe House 2 - October 18 & 19 INu's Battles #13 - ByuN vs Zoun Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
Is there anyway to get a private coach? BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ BSL Season 21 OGN to release AI-upscaled StarLeague from Feb 24
Tourneys
300$ 3D!Community Brood War Super Cup #4 [ASL20] Semifinal B Azhi's Colosseum - Anonymous Tournament [Megathread] Daily Proleagues
Strategy
Current Meta Roaring Currents ASL final [I] Funny Protoss Builds/Strategies BW - ajfirecracker Strategy & Training
Other Games
General Games
Path of Exile Nintendo Switch Thread Stormgate/Frost Giant Megathread Dawn of War IV ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine The Chess Thread US Politics Mega-thread Russo-Ukrainian War Thread Men's Fashion Thread
Fan Clubs
The herO Fan Club!
Media & Entertainment
Anime Discussion Thread Series you have seen recently... [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Our Last Hope in th…
KrillinFromwales
Certified Crazy
Hildegard
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1062 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
Hyrule19144 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
Hyrule19144 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 2h 21m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 110
StarCraft: Brood War
Aegong 68
ToSsGirL 48
Mong 1
Dota 2
XaKoH 212
XcaliburYe123
canceldota63
League of Legends
JimRising 695
Counter-Strike
Stewie2K614
Coldzera 283
shoxiejesuss261
Other Games
summit1g7312
WinterStarcraft408
ceh9400
Tasteless167
Hui .108
Mew2King76
Trikslyr15
Organizations
Other Games
gamesdonequick764
Counter-Strike
PGL249
Other Games
BasetradeTV72
StarCraft: Brood War
UltimateBattle 30
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• LUISG 23
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV530
League of Legends
• Lourlo1203
• Jankos1042
• Stunt686
Upcoming Events
Replay Cast
2h 21m
OSC
8h 21m
Tenacious Turtle Tussle
15h 21m
The PondCast
1d 2h
OSC
1d 4h
WardiTV Invitational
2 days
Online Event
2 days
RSL Revival
2 days
RSL Revival
3 days
WardiTV Invitational
3 days
[ Show More ]
Afreeca Starleague
4 days
Snow vs Soma
Sparkling Tuna Cup
4 days
WardiTV Invitational
4 days
CrankTV Team League
4 days
RSL Revival
4 days
Wardi Open
5 days
CrankTV Team League
5 days
Replay Cast
6 days
WardiTV Invitational
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 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.