There is a Postgresql database, it has a label with date fields
journal=# show styleshift; ERROR: unrecognized configuration parameter "styleshift" journal=# show datestyle; DateStyle ------------- German, DMY (1 row) journal=# Driver to access the database
https://github.com/lib/pq
The date format I need is 02/01/2006, it is this in the database
journal=# select * from j_nar limit 2; id | id_patient | number_nar | date_open_nar | date_close_nar ----+------------+------------+---------------+---------------- 34 | 33 | 777 | 01.03.2017 | 05.03.2017 35 | 34 | 111 | 18.03.2017 | 18.03.2017 (2 rows) journal=# From the html form, the data comes in this form:
2017-04-01
The database is already stored as follows:
04/01/2017
From the server on the frontend output as follows.
type ListNar struct { Id int64 `json:"Id"` IdPatient int64 `json:"IdPatient"` NumberNar string `json:"NumberNar"` DateOpenNar string `json:"DateOpen"` DateCloseNar string `json:"CloseOpen"` } func ModelListNar(id string)[]*ListNar { query := "SELECT id, id_patient, number_nar, date_open_nar, date_close_nar FROM j_nar WHERE id_patient = " + id + " order by id" rows := db.Select(query) bks := make([]*ListNar, 0) for rows.Next() { bk := new(ListNar) rows.Scan(&bk.Id, &bk.IdPatient ,&bk.NumberNar, &bk.DateOpenNar, &bk.DateCloseNar) bks = append(bks, bk) } return bks } func ListNar(w http.ResponseWriter, rnd render.Render) { bks := ModelListNar(currentId.id) b, _ := json.Marshal(bks) fmt.Fprintf(w, "%s \n", b) } On the frontend I get data of this kind:
2017-04-01T00: 00: 00Z
In the structure, I have not specified the format of the time.Time field. Why is this happening and how to fix it.
date_open_naranddate_close_narin your database? - Ainar-G