---
title: "Discussion on \"Easy Date Handling in JavaScript with apex.date\" | Hashnode"
description: "Discussion on \"Easy Date Handling in JavaScript with apex.date\". Working with dates and times in JavaScript is painful. Don't worry, the Oracle APEX JavaScript API apex.date makes working with dates and times a breeze."
url: "https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Easy Date Handling in JavaScript with apex.date](https://blog.cloudnueva.com/apex-date-js-api?utm_source=hashnode&utm_medium=feed)

Working with dates and times in JavaScript is painful. Don't worry, the Oracle APEX JavaScript API apex.date makes working with dates and times a breeze.

Aug 18, 2022 · 3 min read · blog.cloudnueva.com  
Updated Aug 19, 2022  
Read the article

-   [#oracle](https://hashnode.com/tag/oracle)
-   [#orclapex](https://hashnode.com/tag/orclapex)

## Written by

[Jon Dixon](https://hashnode.com/@orclapex)

@orclapex · San Diego, CA

  
[View profile](https://hashnode.com/@orclapex)

APEX, ORDS & the Oracle Database

I’m Jon Dixon, an Oracle APEX developer and consultant at Cloud Nueva. I write about APEX, ORDS, the Oracle Database, and how AI is changing the way we build software. This blog is where I share practical examples, lessons learned, and ideas from my work.

## Responses 2

Markdown supported · ⌘↵ to post

[Sam](https://hashnode.com/@sabenjamin)

[May 31, 2023](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/647765c98d2851ce07115daf)

Hello John

Thanks for writing this document its been very helpful I am in the process of trying to get a constant line or marker to appear on selected dates on a gantt chart. So far are ive been able to display selected dates but unable to select an extended period, multiple weekends or an entire month. Could you please advise on how to do this?

[Jon Dixon](https://hashnode.com/@orclapex)

[Jun 1, 2023](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/647765c98d2851ce07115daf#reply-64781444ca1f2ed6f7975b8f)

Hi Sam, Sorry I do not know enough about the APEX Gantt chart to know how to do this.

[Academic City](https://hashnode.com/@tmmpodcastgh)

[Nov 10, 2023](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/647765c98d2851ce07115daf#reply-654e67980701ac13578c259f)

Hi John, To be able to select an extended period, multiple weekends or an entire month. You have to use you can leverage the customGridLines property. This property allows you to add custom grid lines to the Gantt chart, effectively creating markers on specific dates. You can use a for loop through these dates and it will be displayed on your chart. This is a code sample to achieve this

// Assume you have an array of selected dates var selectedDates = \["2023-11-15", "2023-11-22", "2023-12-01"\];

// Loop through the selected dates and add custom grid lines for (var i = 0; i < selectedDates.length; i++) { apex.jQuery("#GANTT\_CHART\_ID").ganttChart("addCustomGridLine", { value: selectedDates\[i\], label: "Selected Date", style: { stroke: "red", // You can customize the line color "stroke-width": 2 } }); } Replace "GANTT\_CHART\_ID" with the actual ID of your Gantt chart region.

Let me know if you need further clarification on this

[Eric Sacramento](https://hashnode.com/@ericsacramento)

[Aug 18, 2022](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/62fe8a0cf1a220fcdbb6516f)

Hi Jon,

I think in example 2 the code

```
apex.message.clearErrors();
```

should be executed outside the if condition. Because if the user fixes the error, the message will go away.

Thank you for your time.

Eric

[Jon Dixon](https://hashnode.com/@orclapex)

[Aug 19, 2022](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/62fe8a0cf1a220fcdbb6516f#reply-62ff8dd267b2030c206c1ea4)

Hi Eric, You are quite right, I have fixed it. Thanks for letting me know.
