Skip to content

Chart for timestamp, way of display #45

Closed Answered by graphieros
manulsan asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @manulsan ^^

There is no formatting made by the library for timestamps, it only displays the strings you pass to the config.

I recommend you use your own formatting function (or use a library for that).
Here is a function you can use to format your time:

function convertTimestampToAmPm(timestamp) {
    const timestampRegex = /^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;

    const match = timestamp.match(timestampRegex);
    if (!match) {
        return "Invalid timestamp format. Please use 'YYYY/MM/DD HH:MM:SS'.";
    }

    const [_, year, month, day, hoursStr, minutesStr, secondsStr] = match;

    const date = new Date(`${year}-${month}-${day}T${hoursStr}:${minutesStr}:${se…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@manulsan
Comment options

@manulsan
Comment options

@graphieros
Comment options

Answer selected by graphieros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants