Working with Date and Time in BAS
The Date and Time module in Browser Automation Studio — how BAS stores time as UNIX milliseconds, and the actions to create, convert, compare and shift dates and timezones.
Automation runs on time: timestamps, intervals, “wait until tomorrow,” “only post every six hours.” The Date and Time module gives BAS a precise, consistent way to handle all of it.
How BAS stores time
BAS uses its own representation of date and time, built on UNIX time — the number of milliseconds since midnight UTC on 1 January 1970 (the “UNIX epoch”). UNIX time aligns with UTC and is the standard encoding operating systems use.
Storing time as a single number of milliseconds has real advantages: it’s trivial to compare two dates down to the millisecond, it converts cleanly to any human-readable format, and it’s compact — just 4 or 8 bytes. For large volumes it’s far more efficient to keep time as one value than as a bag of separate fields.
What the module can do
The module is rich in actions for every common need:
- Convert a date to a string and a string back to a date.
- Convert milliseconds to a date and back.
- Create a date explicitly, or get the current date now.
- Add seconds to a date and compute the difference between two dates.
- Change a date’s timezone and read its timezone.
- Extract parts: day of month, day of week, year, month, week, hours, minutes, seconds, milliseconds.
When to reach for it
Use it whenever your bot needs to stamp data with a time, measure how long since something happened, gate an action behind an interval, or align records to a timezone. If you’re scheduling a script to run at a specific time, this module covers the logic — or you can lean on the built-in scheduler. Either way, because everything sits on UNIX milliseconds underneath, your time math stays consistent no matter how you display it.
FAQ
How does BAS represent date and time?
BAS uses its own representation based on UNIX time — the number of milliseconds since midnight UTC on 1 January 1970. It is compact and easy to compare or convert to any human-readable format.
Can BAS schedule a script to run at a specific time?
Yes. The Date and Time module is rich enough to drive time-based logic, and BAS also has a built-in scheduler. Use either to run a scenario at a particular moment.
- Browser Automation Studio: The Complete Practical GuideGuide
- Building Your First Bot in Browser Automation StudioA step-by-step walkthrough of creating your first working BAS bot — from a blank project to a flow that navigates, extracts data, and runs in multiple threads.
- Setting Up Proxies in Browser Automation StudioHow to configure proxies in BAS the right way — proxy types, per-thread assignment, rotation, and the checks that keep multi-account bots from getting flagged.
- Finding Elements in BAS: Selectors That Don't BreakHow element search works in Browser Automation Studio — CSS vs XPath selectors, why recorded ones break, and how to write selectors that survive page changes.