Reference documentation and code samples for the Google Maps Route Optimization V1 Client class TimeWindow.
Time windows constrain the time of an event, such as the arrival time at a
visit, or the start and end time of a vehicle.
Hard time window bounds,start_timeandend_time, enforce the earliest
and latest time of the event, such thatstart_time <= event_time <=
end_time. The soft time window lower bound,soft_start_time, expresses a
preference for the event to happen at or aftersoft_start_timeby incurring
a cost proportional to how long before soft_start_time the event occurs. The
soft time window upper bound,soft_end_time, expresses a preference for the
event to happen at or beforesoft_end_timeby incurring a cost proportional
to how long aftersoft_end_timethe event occurs.start_time,end_time,soft_start_timeandsoft_end_timeshould be within the global time limits
(seeShipmentModel.global_start_timeandShipmentModel.global_end_time)
and should respect:
0 <= `start_time` <= `end_time` and
0 <= `start_time` <= `soft_start_time` and
0 <= `soft_end_time` <= `end_time`.
Generated from protobuf messagegoogle.maps.routeoptimization.v1.TimeWindow
A cost per hour added to other costs in the model if the event occurs before soft_start_time, computed as:max(0, soft_start_time - t.seconds) * * cost_per_hour_before_soft_start_time / 3600, t being the time of the event.This cost must be positive, and the field can only be set if soft_start_time has been set.
↳ cost_per_hour_after_soft_end_time
float
A cost per hour added to other costs in the model if the event occurs aftersoft_end_time, computed as:max(0, t.seconds - soft_end_time.seconds) * * cost_per_hour_after_soft_end_time / 3600, t being the time of the event.This cost must be positive, and the field can only be set ifsoft_end_timehas been set.
getStartTime
The hard time window start time. If unspecified it will be set toShipmentModel.global_start_time.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Maps Route Optimization V1 Client - Class TimeWindow (0.4.1)\n\nVersion latestkeyboard_arrow_down\n\n- [0.4.1 (latest)](/php/docs/reference/maps-routeoptimization/latest/V1.TimeWindow)\n- [0.4.0](/php/docs/reference/maps-routeoptimization/0.4.0/V1.TimeWindow)\n- [0.3.3](/php/docs/reference/maps-routeoptimization/0.3.3/V1.TimeWindow)\n- [0.2.0](/php/docs/reference/maps-routeoptimization/0.2.0/V1.TimeWindow)\n- [0.1.0](/php/docs/reference/maps-routeoptimization/0.1.0/V1.TimeWindow) \nReference documentation and code samples for the Google Maps Route Optimization V1 Client class TimeWindow.\n\nTime windows constrain the time of an event, such as the arrival time at a\nvisit, or the start and end time of a vehicle.\n\nHard time window bounds, `start_time` and `end_time`, enforce the earliest\nand latest time of the event, such that `start_time \u003c= event_time \u003c=\nend_time`. The soft time window lower bound, `soft_start_time`, expresses a\npreference for the event to happen at or after `soft_start_time` by incurring\na cost proportional to how long before soft_start_time the event occurs. The\nsoft time window upper bound, `soft_end_time`, expresses a preference for the\nevent to happen at or before `soft_end_time` by incurring a cost proportional\nto how long after `soft_end_time` the event occurs. `start_time`, `end_time`,\n`soft_start_time` and `soft_end_time` should be within the global time limits\n(see\n[ShipmentModel.global_start_time](/php/docs/reference/maps-routeoptimization/latest/V1.ShipmentModel#_Google_Maps_RouteOptimization_V1_ShipmentModel__getGlobalStartTime__)\nand\n[ShipmentModel.global_end_time](/php/docs/reference/maps-routeoptimization/latest/V1.ShipmentModel#_Google_Maps_RouteOptimization_V1_ShipmentModel__getGlobalEndTime__))\nand should respect: \n\n 0 \u003c= `start_time` \u003c= `end_time` and\n 0 \u003c= `start_time` \u003c= `soft_start_time` and\n 0 \u003c= `soft_end_time` \u003c= `end_time`.\n\nGenerated from protobuf message `google.maps.routeoptimization.v1.TimeWindow`\n\nNamespace\n---------\n\nGoogle \\\\ Maps \\\\ RouteOptimization \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getStartTime\n\nThe hard time window start time. If unspecified it will be set to\n`ShipmentModel.global_start_time`.\n\n### hasStartTime\n\n### clearStartTime\n\n### setStartTime\n\nThe hard time window start time. If unspecified it will be set to\n`ShipmentModel.global_start_time`.\n\n### getEndTime\n\nThe hard time window end time. If unspecified it will be set to\n`ShipmentModel.global_end_time`.\n\n### hasEndTime\n\n### clearEndTime\n\n### setEndTime\n\nThe hard time window end time. If unspecified it will be set to\n`ShipmentModel.global_end_time`.\n\n### getSoftStartTime\n\nThe soft start time of the time window.\n\n### hasSoftStartTime\n\n### clearSoftStartTime\n\n### setSoftStartTime\n\nThe soft start time of the time window.\n\n### getSoftEndTime\n\nThe soft end time of the time window.\n\n### hasSoftEndTime\n\n### clearSoftEndTime\n\n### setSoftEndTime\n\nThe soft end time of the time window.\n\n### getCostPerHourBeforeSoftStartTime\n\nA cost per hour added to other costs in the model if the event occurs\nbefore soft_start_time, computed as: \n\n max(0, soft_start_time - t.seconds)\n * cost_per_hour_before_soft_start_time / 3600,\n t being the time of the event.\n\nThis cost must be positive, and the field can only be set if\nsoft_start_time has been set.\n\n### hasCostPerHourBeforeSoftStartTime\n\n### clearCostPerHourBeforeSoftStartTime\n\n### setCostPerHourBeforeSoftStartTime\n\nA cost per hour added to other costs in the model if the event occurs\nbefore soft_start_time, computed as: \n\n max(0, soft_start_time - t.seconds)\n * cost_per_hour_before_soft_start_time / 3600,\n t being the time of the event.\n\nThis cost must be positive, and the field can only be set if\nsoft_start_time has been set.\n\n### getCostPerHourAfterSoftEndTime\n\nA cost per hour added to other costs in the model if the event occurs after\n`soft_end_time`, computed as: \n\n max(0, t.seconds - soft_end_time.seconds)\n * cost_per_hour_after_soft_end_time / 3600,\n t being the time of the event.\n\nThis cost must be positive, and the field can only be set if\n`soft_end_time` has been set.\n\n### hasCostPerHourAfterSoftEndTime\n\n### clearCostPerHourAfterSoftEndTime\n\n### setCostPerHourAfterSoftEndTime\n\nA cost per hour added to other costs in the model if the event occurs after\n`soft_end_time`, computed as: \n\n max(0, t.seconds - soft_end_time.seconds)\n * cost_per_hour_after_soft_end_time / 3600,\n t being the time of the event.\n\nThis cost must be positive, and the field can only be set if\n`soft_end_time` has been set."]]