I have a PHP API that takes time in format of YYYYMMWDDHHMMSS. Here W is weekday(Sunday=0, Monday = 1 ...). I am trying to generate the it like following:
package main
import "fmt"
import "time"
func main() {
fmt.Println("Hello, playground")
t := time.Now()
time := t.Format("20060102030405")
fmt.Println(time)
}
http://play.golang.org/p/Tdamoxi3bE
But it does not have weekday in it and i couldn't find any format to get from time.Format. Is there any way to get the desired result from time.Format() or any other go api.
package main
import "fmt"
import "strconv"
import "time"
func main() {
fmt.Println("Hello, playground")
t := time.Now()
time := t.Format("20060102030405")
time = time[:6] + strconv.Itoa(int(t.Weekday())) + time[6:]
fmt.Println(time)
}
Try it on the Go playground