How does one export the day of the month from Zotero to BibTeX?

Hi All

When I export from Zotero to BibTeX, I need the day of the month to be exported, because I need it with the month and year in the references. This is because I am citing reports from several organisations that come out daily or weekly. Using Better BibTeX, putting this in the Postscript:
reference.add({name: 'date', value:});

Gives me this in the *.bib file:
date = {2020-07-04}

So, that means that the day of the month can be exported, but I do not know how to extract it from "2020-07-04". Unfortunately, I do not know JavaScript, but I guess that I can hack my way around it with a bit of help. I need one of the following:
(1) The details of a function in Zotero that extracts the day of the month from
(2) The details of a function in Better BibTeX that extracts the day of the month from
(3) What is "2020-07-04" within Zotero/Better BibTeX before it gets exported: a string or an array? Could something like be used to break up the date so I can get at the day of the month?
(4) A JavaScript function that I can use to extract the day of the month from "2020-07-04".

I am dealing with an old and buggy citation style in LaTeX (for a chapter in a book), so I need to produce something like:
month = "4~" # jul,
year = 2020,

If I could just get the day of the week, I think that I could put together the JavaScript snippet to use in Better BibTeX's Postscript.

I have trawled through a lot of documentation and source code, but I have not been able to find the solution, so I hope that one of you can help me.

Thank you
  • In a postscript, you have access to, which is as it is entered in Zotero. You can do something like reference.add({ name: 'month', bibtex: '"4~" # jul' }) to output exactly that. You can use the BBT dateparser or Zotero's dateparser to fetch the DOM from the raw date text.
  • Dear Emiliano

    Thank you very much for your prompt response, but where do I find documentation on either of the dateparsers?

    Thank you
  • edited July 5, 2020
    I don't know about the Zotero dateparser.

    The BBT dateparser returns dates as objects with the following properties:

    type: 'date' | 'season' | 'open' | 'interval' | 'list' | 'verbatim'

    this property determines what the rest of the object will look like:

    • when type is ‘date’, the object will have a year, may have a month, but only if it has a year, and may have a day, but only when it has a month & year. It may have properties approximate and/or uncertain

    • when type if ‘season’, the object will have a year and a season

    • when type is ‘open’, it will have no other properties

    • when type is ‘interval’, it will have properties from and to, each being dates of type ‘date’, ‘season’ or ‘open’

    • when type is ‘list’, it will have a property dates, which will be a list of dates of type ‘date’, ‘season’, ‘interval’ or ‘verbatim’

    • when type is ‘verbatim’, that means the date parser could not make sense of the input as a date, and the original value can be found on property verbatim

    So in your case you could do something like (untested)

    if (Translator.BetterBibTeX && reference.has.month) {
    const date = Zotero.BetterBibTeX.parseDate(
    if (date.type === 'date' && {
    const month = [ null, 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ][date.month]
    reference.add({ name: 'month', bibtex: `"${}~" # ${month}` })
  • Wait, you want day of week, not day of month?
  • Dear Emiliano

    Excellent, thank you very much. I wanted the day of the month.

    I found that reference.has.month does not seem to work, but I think that it is redundant in any case, because of the use of in the following if statement: I only need the code snippet to run if there is a day of the month. The following works for me:

    if (translator.BetterBibTeX) {
    const date = Zotero.BetterBibTeX.parseDate(;
    if (date.type === 'date' && {
    const month = [ null, 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ][date.month]
    reference.add({ name: 'month', bibtex: `"${}~" # ${month}` })

  • if you're exporting to bibtex, and you can find a day in the date, reference should inescapably have a month. If that's not the case for you, I'd appreciate an issue being opened on github so I can understand what's going on.
  • Dear Emiliano

    I have added the following issue on Github:

    reference.has.month does not seem to work #1564

    I hope that I did it correctly, because I have never done it before.

    Thank you
  • Thank you, we'll take it from there.
Sign In or Register to comment.