Date for a comic?

Things that don't belong anywhere else. (Check first).

Moderators: Moderators General, Prelates, Magistrates

Posts: 1
Joined: Mon Apr 10, 2017 1:18 pm UTC

Date for a comic?

Postby wynlyndd » Mon Apr 10, 2017 1:21 pm UTC

I am looking for a date for the above comic. Am I not seeing it?

User avatar
GNU Terry Pratchett
Posts: 26767
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There

Re: Date for a comic?

Postby gmalivuk » Mon Apr 10, 2017 4:52 pm UTC

Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome


User avatar
Posts: 4890
Joined: Fri May 10, 2013 7:13 pm UTC
Location: England

Re: Date for a comic?

Postby HES » Mon Apr 10, 2017 4:58 pm UTC

Dates for comics can be found as hovertext on the archive page.
He/Him/His Image

User avatar
PM 2Ring
Posts: 3713
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: Date for a comic?

Postby PM 2Ring » Tue Apr 11, 2017 9:14 am UTC

You can get the date of a comic from the JSON feed. For that comic, the JSON is at Your browser may have an extension that formats JSON data nicely.

Or if you have Python and you aren't afraid to use the command line, you can use the following script to fetch the JSON and display the comic's title and publication data. This script will run on both Python 2 and Python 3. I've also made it locale-aware so it prints the month name in the local language.

Code: Select all

#!/usr/bin/env python3

''' xkcd_pubdate

    Fetch the title and publication date of an xkcd comic
    If no number is given on the commandline, get the data
    for the current comic.

    Written by PM 2Ring 2017.04.11

from __future__ import print_function
import sys
, json
import locale
from calendar import month_name

# Set the locale so we get month names in the local language
locale.setlocale(locale.LC_TIME, '')

    # Python 3
    from urllib.request import urlopen
    from urllib
.error import URLError
except ImportError
    #Python 2
    from urllib import urlopen
= IOError

def main
    # Get the comic number & build the URL.
    # If no number is given, we get the current comic.
    num = sys.argv[1] if len(sys.argv) > 1 else ''
    url = '' + num + '/info.0.json'
    #print('URL =', url)

        # Fetch the JSON data for the comic
        f = urlopen(url)
        json_data =

        # Load the JSON string into a Python dictionary
        xkcd = json.loads(json_data)
    except (URLError, ValueError) as e:
        print('ERROR:', e)
        raise SystemExit(1)

    # Convert the month number to its name in the current locale
    xkcd['month'] = month_name[int(xkcd['month'])]

    # Display the data
    fmt = 'xkcd #{num}\nTitle: {title}\nPublished: {day} {month} {year}'

    # Uncomment the following line to see all of the JSON data
    #print(json.dumps(xkcd, indent=4))

if __name__ == '__main__':


python 1425

prints the following (assuming you use an English locale):

Code: Select all

xkcd #1425
Title: Tasks
Published: 24 September 2014

If you're on Linux or another Unix-like system and you want to see the month name in French, try

LANG=fr_FR.utf8 python

Other xkcd comic fetching programs can be found in the Coding forum in the Getting the most recent comic sticky thread.

Return to “General”

Who is online

Users browsing this forum: No registered users and 21 guests