-
-
Save parzibyte/9234f78b5207f7de2bff38a9d2b4f98b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
/* | |
https://parzibyte.me/blog | |
*/ | |
fecha := "2021-10-21T22:12:53" | |
fechaComoTime, err := time.Parse("2006-01-02T15:04:05", fecha) | |
if err != nil { | |
fmt.Println("Error parseando fecha") | |
fmt.Println(err) | |
return | |
} | |
// Hasta aquí todo bien | |
fmt.Println("Fecha original: ") | |
fmt.Println(fechaComoTime) | |
dentroDeUnaHora := fechaComoTime.Add(time.Hour * 1) | |
fmt.Println("Fecha dentro de una hora: ") | |
fmt.Println(dentroDeUnaHora) | |
haceDosDias := fechaComoTime.Add((time.Hour * 24 * 2) * -1) | |
fmt.Println("Fecha hace dos días") | |
fmt.Println(haceDosDias) | |
dentroDe57Dias := fechaComoTime.Add(time.Hour * 24 * 57) | |
fmt.Println("Fecha dentro de 57 días:") | |
fmt.Println(dentroDe57Dias) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment