github.com/zhongdalu/gf@v1.0.0/g/os/gfile/gfile_time.go (about)

     1  // Copyright 2017-2018 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/zhongdalu/gf.
     6  
     7  package gfile
     8  
     9  import (
    10  	"os"
    11  )
    12  
    13  // MTime returns the modification time of file given by <path> in second.
    14  func MTime(path string) int64 {
    15  	s, e := os.Stat(path)
    16  	if e != nil {
    17  		return 0
    18  	}
    19  	return s.ModTime().Unix()
    20  }
    21  
    22  // MTimeMillisecond returns the modification time of file given by <path> in millisecond.
    23  func MTimeMillisecond(path string) int64 {
    24  	s, e := os.Stat(path)
    25  	if e != nil {
    26  		return 0
    27  	}
    28  	return int64(s.ModTime().Nanosecond() / 1000000)
    29  }