npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

getfiledate

v1.0.0

Published

Get the date and time of the last edit or date created of files and folders

Readme

logo

Get the date and time of the last edit by default (/D is optional), the date created with /C flag, or get both with /B flag of files and folders.

Built with TypeScript - Includes full type definitions for use in TypeScript projects.

Installation

npm install -g getfiledate

Or clone and install locally:

git clone https://github.com/jhauga/getFileDate.git
cd getFileDate
npm install
npm run build
npm link

Usage

getFileDate [flags] [options] [files...]

Flags

Flags control which date type to display:

  • /B - Output both date of last edit and date created
  • /C - Output only the date created
  • /D - Output the last edit date (default)

Note: Flags are case-insensitive (/b, /c, /d also work)

Options

  • -d, --date [files...] - Get only the date
  • -t, --time [files...] - Get only the time
  • -h, --help - Show help message
  • --version - Show version number

Option Parameters

Some options support additional parameters:

  • --date:slash - Use slash (/) as date separator instead of dash (-)
  • --date:dash - Use dash (-) as date separator (default)

Combining Options

Short options can be combined for convenience:

-dt          # Get date and time

Important: When combining options, only the last option can have a parameter.

Valid Examples

-dt file.txt               # Get date and time
-d:slash file.txt          # Get date with slash separator

Examples

Basic Usage

List all files and folders in current directory with last edit date and time:

getFileDate

Output:

03-03-2026   01:57 PM   .
03-03-2026   01:37 PM   ..
03-03-2026   01:57 PM   .github
03-03-2026   01:57 PM   getFileDate.code-workspace
03-03-2026   01:57 PM   task.bat

Using Flags

Show created date only:

getFileDate /C

Output:

03-03-2026   02:57 AM   .
03-03-2026   02:37 AM   ..
03-03-2026   02:57 AM   .github
03-03-2026   02:57 AM   getFileDate.code-workspace

Show both created and last edit dates:

getFileDate /B

Output:

[created]   03-03-2026   01:57 PM   .
[last edit] 03-03-2026   02:57 AM   .
[created]   03-03-2026   01:37 PM   ..
[last edit] 03-03-2026   02:37 AM   ..
[created]   03-03-2026   01:57 PM   .github
[last edit] 03-03-2026   02:57 AM   .github

Using Options

Get only the date:

getFileDate --date

Output:

03-03-2026   .
03-03-2026   ..
03-03-2026   .github

Get only the time:

getFileDate --time

Output:

01:57 PM   .
01:37 PM   ..
01:57 PM   .github

Single File Output

When specifying a single file, the filename is not shown in output:

getFileDate -d file.txt

Output:

03-03-2026
getFileDate -t file.txt

Output:

01:57 PM

Date Separator Options

Use slash separator instead of dash:

getFileDate --date:slash file.txt

Output:

03/03/2026

Multiple Files

Specify multiple files separated by commas:

getFileDate -d fileA.txt,fileB.txt,fileC.txt

Output:

03-03-2026   fileA.txt
03-03-2026   fileB.txt
03-03-2026   fileC.txt

Complex Examples

Combine flags and options:

getFileDate /C -t fileA.txt -d fileB.txt /D fileC.txt

Output:

01:57 AM   fileA.txt
03-03-2026 fileB.txt
01:57 PM   fileC.txt

API Usage

You can also use getFileDate as a library in your Node.js or TypeScript projects:

JavaScript

const { getFileDates, formatDate, formatTime, formatBoth } = require('getfiledate');

async function example() {
  // Get file dates
  const dates = await getFileDates('./myfile.txt');
  console.log('Created:', dates.created);
  console.log('Modified:', dates.modified);

  // Format dates
  const formattedDate = formatDate(dates.modified, '-');
  console.log('Date:', formattedDate); // e.g., "03-03-2026"

  const formattedTime = formatTime(dates.modified);
  console.log('Time:', formattedTime); // e.g., "01:57 PM"

  const formattedBoth = formatBoth(dates.modified, '-');
  console.log('Both:', formattedBoth); // e.g., "03-03-2026   01:57 PM"
}

example();

TypeScript

import { getFileDates, formatDate, formatTime, formatBoth, FileDates } from 'getfiledate';

async function example(): Promise<void> {
  // Get file dates - fully typed!
  const dates: FileDates = await getFileDates('./myfile.txt');
  console.log('Created:', dates.created);
  console.log('Modified:', dates.modified);

  // Format dates with type-safe parameters
  const formattedDate: string = formatDate(dates.modified, '-');
  console.log('Date:', formattedDate); // e.g., "03-03-2026"

  const formattedTime: string = formatTime(dates.modified);
  console.log('Time:', formattedTime); // e.g., "01:57 PM"

  const formattedBoth: string = formatBoth(dates.modified, '/');
  console.log('Both:', formattedBoth); // e.g., "03/03/2026   01:57 PM"
}

example();

Available Types

interface FileDates {
  created: Date;
  modified: Date;
}

function getFileDates(filePath: string): Promise<FileDates>;
function formatDate(date: Date, separator?: string): string;
function formatTime(date: Date): string;
function formatBoth(date: Date, separator?: string): string;
function padString(str: string, width: number): string;

Development

Building from Source

npm run build        # Build the project
npm run watch        # Build and watch for changes
npm run clean        # Clean build artifacts

Running Tests

npm test

Project Structure

getFileDate/
├── src/
│   ├── bin/
│   │   └── getFileDate.ts      # CLI executable (TypeScript)
│   └── lib/
│       ├── index.ts            # Core date/time functions (TypeScript)
│       └── argParser.ts        # Argument parsing logic (TypeScript)
├── test/
│   └── test.ts                 # Test suite (TypeScript)
├── dist/                       # Compiled JavaScript output
├── tsconfig.json               # TypeScript configuration
├── .gitignore
├── LICENSE
├── package.json
└── README.md

Requirements

  • Node.js >= 14.0.0
  • TypeScript >= 5.0.0 (for development only)

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.