TIP: Easy way to get a date at midnight


not sure if common knowledge, searching internet on subject turns solutions using nsdatecomponents fine. here quick , easy way have found nsdateformatter.

code:
 dateatmidnightformatter = [[nsdateformatter alloc] init]; [dateatmidnightformatter setdatestyle:nsdateformattershortstyle]; [dateatmidnightformatter settimestyle:nsdateformatternostyle];  nsdate *todayatmidnight = [dateatmidnightformatt datefromstring:[dateatmidnightformatter stringfromdate:[nsdate date] ] ]; 
john
 



Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments