title: How to find a weekday from the given date in string?
body: <p>I have a function in my app that saves the date in string into the database, but it can't save the day on that date. I have tried a short code on this. Suppose we have a date in string.</p>
  
  <p>Code:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "strconv"
      "strings"
      "time"
  )   
  
  func main() {
      p := fmt.Println
      date := "01-25-2019"
      arrayDate := strings.Split(date, "-")
      fmt.Println(arrayDate)
      month, _ := strconv.Atoi(arrayDate[0])
      dateInt, _ := strconv.Atoi(arrayDate[1])
      year, _ := strconv.Atoi(arrayDate[2])
      then := time.Date(
          year, time.Month(month), dateInt, 0, 0, 0, 0, time.UTC)
      p(then)
  
      p(then.Weekday())
  
  }
  </code></pre>
  
  <p>Is there any more efficient way to do this?</p>
  
  <p>playground <a href="https://play.golang.org/p/TGeXz6Ev-EE" rel="nofollow noreferrer">link</a></p>