1.90 Time .768 1.90.1 Time.AddDays .768 1.90.2 Time.AddFlours .768 1.90.3 Time.AddMinutes .769 1.90.4 Time.AddMonths .770 1.90.5 Time.AddSeconds .770 1.90.6 Time.AddWeeks .771 1.90.7 Time.AddYears .772 1.90.8 Time.ConvertToLocal .772 1.90.9 Time.ConvertTolltc .773 1.90.10 Time.Copy .774 1.90.11 Time.Create .774 1.90.12 Time.GetAsPosixTimestamp .775 1.90.13 Time.GetDate .775 1.90.14 Time.GetDayOfMonth .776 1.90.15 Time.GetDayOfWeek .776 1.90.16 Time.GetDifference .777 1.90.17 Time.GetDifferencelnDays .778 1.90.18 Time.GetDifferencelnHours .779 1.90.19 Time.GetDifferencelnMinutes .779 1.90.20 Time.GetDifferencelnMonths.780 1.90.21 Time.GetDifferencelnSeconds .781 1.90.22 Time.GetDifferencelnWeeks .781 1.90.23 Time.GetDifferencelnYears .782 1.90.24 Time.GetHour .783 1.90.25 Time.GetMinute .783 1.90.26 Time.GetMonth .784 1.90.27 Time.GetSecond .785 1.90.28 Time.GetTime .785 1.90.29 Time.GetYear .786 1.90.30 Time.lsValid .786 1.90.31 Time.SetDayOfMonth .787 1.90.32 Time.SetFromLocal .787 1.90.33 Time.SetFromPosixTimestamp .788 1.90.34 Time.SetFromServer .788 1.90.35 Time.SetFlour .789 1.90.36 Time.SetMinute .790 1.90.37 Time.SetMonth .790 1.90.38 Time.SetSecond .791 1.90.39 Time.SetYear .791 Time Time. Add Days Brief Add a specified number of days to the stored time. Definition ! Time.AddDays(Time t, number days) Arguments t - Time to modify.days - Number of days to add. Negative values will cause subtraction. Return Values None. Description Adds the specified number of days onto the time stored in the time object. Will correctly account for month lengths and leap years. To subtract, pass a negative value for days. Only integer values are permitted, fractional values will be truncated. Examples ! time = Time.Create () i time:SetFromServer() j time:AddDays(90) — add 90 days onto the current server time See Also • Time.AddMinutes • Time.AddHours • Time.AddSeconds • Time.AddWeeks • Time.AddMonths • Time.AddYears Time.AddHours Brief Add a specified number of hours to the stored time. Definition ! Time.AddHours(Time t, number hours) Arguments t - Time to modify.hours - Number of hours to add. Negative values will cause subtraction. Return Values None. Description Adds the specified number of hours onto the time stored in the time object. Will correctly account for month lengths and leap years. To subtract, pass a negative value for hours. Only integer values are permitted, fractional values will be truncated. Examples time = Time.Create () time:SetFromServer() time:AddHours(60) — add 60 hours onto the current server time See Also • Time.AddMinutes • Time.AddSeconds • Time.AddDays • Time.AddWeeks • Time.AddMonths • Time.AddYears Time.AddMinutes Brief Add a specified number of minutes to the stored time. Definition Time.AddMinutes(Time t, number minutes) Arguments t - Time to modify.minutes - Number of minutes to add. Negative values will cause subtraction. Return Values None. Description Adds the specified number of minutes onto the time stored in the time object. Will correctly account for month lengths and leap years. To subtract, pass a negative value for minutes.Only integer values are permitted, fractional values will be truncated. Examples ! time = Time.Create() i time:SetFromServer() | time:AddMinutes(45) — add 45 minutes onto the current server time See Also Time.AddSeconds • Time.AddHours • Time.AddDays • Time.AddWeeks • Time.AddMonths • Time.AddYears Time.AddMonths Brief Add a specified number of months to the stored time. Definition ! Time.AddMonths(Time t, number months) Arguments t - Time to modify.months - Number of months to add. Negative values will cause subtraction. Return Values None. Description Adds the specified number of months onto the time stored in the time object. Will correctly account for month lengths and leap years. To subtract, pass a negative value for months. Only integer values are permitted, fractional values will be truncated. Examples j time = Time.Create() i time:SetFromServer() > time:AddMonths(6) — add 6 months onto the current server time See Also • Time.AddMinutes • Time.AddHours • Time.AddDays • Time.AddWeeks • Time.AddSeconds • Time.AddYears Time.AddSeconds Brief Add a specified number of seconds to the stored time. Definition Time.AddSeconds(Time t, number seconds) Arguments t - Time to modify.seconds - Number of seconds to add. Negative values will cause subtraction. Return Values None. Description Adds the specified number of seconds onto the time stored in the time object. Will correctly account for month lengths and leap years. To subtract, pass a negative value for seconds. Only integer values are permitted, fractional values will be truncated. Examples ! time = Time.Create () i time:SetFromServer() j time:AddSeconds(30) — add 30 seconds onto the current server time See Also • Time.AddMinutes • Time.AddHours • Time.AddDays • Time.AddWeeks • Time.AddMonths • Time.AddYears Time.AddWeeks Brief Add a specified number of weeks to the stored time. Definition ! Time.AddWeeks(Time t, number weeks) Arguments t - Time to modify.weeks - Number of weeks to add. Negative values will cause subtraction. Return Values None. Description Adds the specified number of weeks onto the time stored in the time object. Will correctly account for month lengths and leap years. To subtract, pass a negative value for weeks. Only integer values are permitted, fractional values will be truncated. Examples time = Time.Create () time:SetFromServer() time:AddWeeks(8) — add 8 weeks onto the current server time See Also • Time.AddMinutes • Time.AddHours • Time.AddDays • Time.AddSeconds • Time.AddMonths • Time.AddYears Time.AddYears Brief Add a specified number of years to the stored time. Definition ! Time.AddYears(Time t, number years) Arguments t - Time to modify.years - Number of years to add. Negative values will cause subtraction. Return Values None. Description Adds the specified number of years onto the time stored in the time object. Will correctly account for month lengths and leap years. To subtract, pass a negative value for years. Only integer values are permitted, fractional values will be truncated. Examples ! time = Time.Create () i time:SetFromServer() | time:AddYears(1) — add 1 year onto the current server time See Also • Time.AddMinutes • Time.AddHours • Time.AddDays • Time.AddWeeks • Time.AddMonths Time.AddSeconds Time.ConvertToLocal Brief Convert the stored time from UTC time to local time. Definition Time.ConvertToLocal(Time t) Arguments t - Time to modify. Return Values None. Description Converts a time specified in UTC time to local time, based on the current system settings. Note that this relies on the user having set the system timezone settings correctly, and as such should not be relied upon for absolute accuracy. Examples local t = Time.Create() i t:SetFromServer() | t:ConvertToLocal() ! print("Current server time in local time is:", t) See Also • Time.ConvertToUtc Time.ConvertT olltc Brief Convert the stored time from local time to UTC time. Definition Time.ConvertToUtc(Time t) Arguments t - Time to modify. Return Values None. Description Converts a time specified in local time to UTC time, based on the current system settings. Note that this relies on the user having set the system timezone settings correctly, and as such should not be relied upon for absolute accuracy. Examples local t = Time.Create() t:SetFromLocal() t:ConvertToUtc() print("Current time in UTC is:", t) See Also • Time.ConvertToLocal Time.Copy Brief Copy a Time value. Definition Time.Copy(Time destination, Time source) Arguments destination - Time value to copy into.source - Time value to copy. Return Values None. Description Copies a Time value from one instance to another. Examples j local timel = Time.Create(2011, 10, 31) j local time2 = Time.Create() j Time.Copy(time2, timel) See Also • Time.Create Time.Create Brief Creates a new Time object. Definition Time Time.Create () Time Time.Create(number year, number month, number day, number hours = 0, number minutes = 0, number seconds = 0) Time Time.Create(Time t) Arguments year - Year to set.month - Month to set.day - Day to set.hours - Hours to set (24 hour time).minutes - Minutes to set.seconds - Seconds to set.t - Time to copy. Return Values A new Time instance. Description Creates a new Time object. By default it is set to 00:00 1/1/1. When defining a specific date/time, invalid date/times will throw a Lua error. Examples j t = Time.Create() See Also None Time.GetAsPosixTimestamp Brief Retrieve the stored time value as a POSIX-compatible 64-bit timestamp. Definition 1 Time.GetAsPosixTimestamp(Time t, Biglnt<64> timestamp) Arguments t - Time object to convert.timestamp - A 64-bit Biglnt value to receive the timestamp. Return Values Description Retrieve the time value converted to a POSIX-compatible 64-bit timestamp (time_t). Examples local timestamp = Biglnt.Create (64) local t = Time.Create() | t:SetFromServer(t) ! t:GetAsPosixTimestamp(timestamp) See Also • Time.SetFromPosixTimestamp Time.GetDate Brief Returns a string representing the date. Definition string Time.GetDate( Time time ) Arguments time - The time object to query. Return Values A string representing the date. Description Returns a string representing the date following the DDMMYYYY, YYYYMMDD, or MMDDYYYY format specified in the XMB. Examples j t = Time.Create() j Time.SetFromLocal( t ) j print( Time.GetTime() ) See Also None Time.GetDayOfMonth Brief Returns the day of the month value. Definition number Time.GetDayOfMonth( Time time ) Arguments time - The time object to query. Return Values The day of the month value, ranging from 1 to 31. Description Returns the day of the month value. Examples j t = Time.Create() i Time.SetFromServer( t ) ! print( 'The server day of the month is ' .. Time.GetDayOfMonth( t ) .. '.' ) See Also None Time.GetDayOfWeek Brief Returns the day of the week value. Definition number Time.GetDayOfWeek( Time time ) Arguments time - The time object to query. Return Values The day of the week value, ranging from 1 (Sunday) to 7 (Saturday). Description Returns the day of the week value. Examples j t = Time.Create() ; Time.SetFromServer( t ) > print( 'The server day of the week is ' .. Time.GetDayOfWeek( t ) .. '.' ) See Also None Time.GetDifference Brief Compute the difference between two Time values in years, months, days, hours, minutes and seconds. Definition number, number, number, number, number, number Time.GetDifference(Time tl. Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The difference from tl to t2 in terms of years, months, days, hours, minutes and seconds, in that order. Description Computes the offset of t2 relative to tl (i.e. the difference will be negative if t2 is earlier than tl, otherwise will be positive). This function is more efficient than using the other GetDifferenceln* functions when requiring more than one unit. However, the individual functions are recommended when only a single unit is needed (e.g. days, weeks, etc). Examples I local now = Time.Create() i now:SetFromServer() local y, m, d, hh, mm, ss = Time.GetDifference(lastSpaceVisit, now) ! print(string.format("You were last here %d years, %d months, %d days, %d hours, %d minutes and %d | seconds ago", y, m, d, hh, mm, ss) ) L_I See Also • Time.GetDifferencelnSeconds • Time.GetDifferencelnMinutes • Time.GetDifferencelnHours • Time.GetDifferencelnMonths • Time.GetDifferencelnYears Time.GetDifferencelnDays Brief Get the difference between two Time values in days. Definition ! number Time.GetDifferencelnDays(Time tl. Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The number of whole days between tl and t2. Description Computes the offset of t2 from tl in days (i.e. the difference will be negative if t2 is earlier than tl, or positive otherwise). If the difference overflows the size of a Lua number, the maximum representable Lua integer will be returned. Examples local t = Time.Create() t:SetFromServer() — if last visit to the space was over 5 days ago if (Time.GetDifferencelnDays(lastVisitTime, t) >= 5) then print("What kept you?") end See Also • Time.GetDifferencelnSeconds • Time.GetDifferencelnMinutes • Time.GetDifferencelnHours • Time.GetDifferencelnYears • Time.GetDifference Time.GetDifferencelnHours Brief Get the difference between two Time values in hours. Definition number Time.GetDifferencelnHours(Time tl, Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The number of whole hours between tl and t2. Description Computes the offset of t2 from tl in hours (i.e. the difference will be negative if t2 is earlier than tl, or positive otherwise). If the difference overflows the size of a Lua number, the maximum representable Lua integer will be returned. Examples local t = Time.Create() t: SetFromServer() — if last server update was over 2 hours ago, upload again if (Time.GetDifferencelnHours(lastServerUpdate, t) >= 2) then UploadToServer() end See Also • Time.GetDifferencelnSeconds • Time.GetDifferencelnMinutes • Time.GetDifferencelnDays • Time.GetDifferencelnYears • Time.GetDifference Time.GetDifferencelnMinutes Brief Get the difference between two Time values in minutes. Definition ! number Time.GetDifferencelnMinutes(Time tl, Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The number of whole minutes between tl and t2. Description Computes the offset of t2 from tl in minutes (i.e. the difference will be negative if t2 is earlier than tl, or positive otherwise). If the difference overflows the size of a Lua number, the maximum representable Lua integer will be returned. Examples local t = Time.Create() t:SetFromServer() — if last server update was over 30 minutes ago, upload again if (Time.GetDifferencelnMinutes(lastServerUpdate, t) >= 30) then UploadToServer() end See Also • Time.GetDifferencelnSeconds • Time.GetDifferencelnHours • Time.GetDifferencelnDays • Time.GetDifferencelnYears • Time.GetDifference Time.GetDifferencelnMonths Brief Get the difference between two Time values in months. Definition ! number Time.GetDifferencelnMonths(Time tl. Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The number of whole months between tl and t2. Description Computes the offset of t2 from tl in months (i.e. the difference will be negative if t2 is earlier than tl, or positive otherwise). If the difference overflows the size of a Lua number, the maximum representable Lua integer will be returned. Examples local t = Time.Create() t:SetFromServer() — if last visit to the space was over 3 months ago if (Time.GetDifferencelnMonths(lastVisitTime, t) >= 3) then print("What kept you?") end See Also • Time.GetDifferencelnSeconds • Time.GetDifferencelnMinutes • Time.GetDifferencelnHours • Time.GetDifferencelnYears • Time.GetDifference Time.GetDifferencelnSeconds Brief Get the difference between two Time values in seconds. Definition ! number Time.GetDifferencelnSeconds(Time tl, Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The number of whole seconds between tl and t2. Description Computes the offset of t2 from tl in seconds (i.e. the difference will be negative if t2 is earlier than tl, or positive otherwise). If the difference overflows the size of a Lua number, the maximum representable Lua integer will be returned. Examples local t = Time.Create() t:SetFromServer() — if last server update was over 2.5 minutes ago, upload again if (Time.GetDifferencelnSeconds(lastServerUpdate, t) >= 150) then UploadToServer() end See Also • Time.GetDifferencelnMinutes • Time.GetDifferencelnHours • Time.GetDifferencelnDays • Time.GetDifferencelnYears • Time.GetDifference Time.GetDifferencelnWeeks Brief Get the difference between two Time values in weeks. Definition number Time.GetDifferencelnWeeks(Time tl, Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The number of whole weeks between tl and t2. Description Computes the offset of t2 from tl in weeks (i.e. the difference will be negative if t2 is earlier than tl, or positive otherwise). If the difference overflows the size of a Lua number, the maximum representable Lua integer will be returned. Examples local t = Time.Create() t:SetFromServer() — if last visit to the space was over 12 weeks ago if (Time.GetDifferencelnWeeks(lastVisitTime, t) >= 12) then print("What kept you?") end See Also • Time.GetDifferencelnSeconds • Time.GetDifferencelnMinutes • Time.GetDifferencelnHours • Time.GetDifferencelnYears • Time.GetDifference Time.GetDifferencelnYears Brief Get the difference between two Time values in years. Definition number Time.GetDifferencelnYears(Time tl. Time t2) Arguments tl - The first time value.t2 - The second time value. Return Values The number of whole years between tl and t2. Description Computes the offset of t2 from tl in years (i.e. the difference will be negative if t2 is earlier than tl, or positive otherwise). If the difference overflows the size of a Lua number, the maximum representable Lua integer will be returned. Examples local t = Time.Create() t:SetFromServer() — if last visit to the space was over 2 years ago if (Time.GetDifferencelnYears(lastVisitTime, t) >= 2) then print("What kept you?") end See Also • Time.GetDifferencelnSeconds • Time.GetDifferencelnMinutes • Time.GetDifferencelnHours • Time.GetDifferencelnMonths • Time.GetDifference Time.GetHour Brief Returns the hour value. Definition ! number Time.GetHour( Time time ) Arguments time - The time object to query. Return Values The hour value, ranging from 0 to 23. Description Returns the hour value. Examples j t = Time.Create() ; Time.SetFromServer( t ) | print( 'The server hour is ' .. Time.GetHour( t ) .. ) See Also None Time.GetMinute Brief Returns the minute value. Definition number Time.GetMinute( Time time ) Arguments time - The time object to query. Return Values The minute value, ranging from 0 to 59. Description Returns the minute value. Examples j t = Time.Create() ; Time.SetFromServer( t ) < print( 'The server minute is ' .. Time.GetMinute( t ) .. ) See Also None Time.GetMonth Brief Returns the month value. Definition number Time.GetMonth( Time time ) Arguments time - The time object to query. Return Values The month value, ranging from 1 to 12. Description Returns the month value. Examples ! t = Time.Create() i Time.SetFromServer( t ) | print( 'The server month is ' .. Time.GetMonth( t ) .. '.' ) See Also None Time.GetSecond Brief Returns the second value. Definition ! number Time.GetSecond( Time time ) Arguments time - The time object to query. Return Values The second value, ranging from 0 to 59. Description Returns the second value. Examples j t = Time.Create() i Time.SetFromServer( t ) « print( 'The server second is ' .. Time.GetSecond( t ) .. ) See Also None Time.GetTime Brief Returns a string representing the time. Definition ! string Time.GetTime( Time time ) Arguments time - The time object to query. Return Values A string representing the time. Description Returns a string representing the time following the 12h or 24h format specified in the XMB. Examples t = Time.Create() Time.SetFromLocal( t ) print( Time.GetTime() ) See Also None Time.GetYear Brief Returns the year value. Definition number Time.GetYear( Time time ) Arguments time - The time object to query. Return Values The year value, ranging from 0 to 9999. Description Returns the year value. Examples j t = Time.Create() i Time.SetFromServer( t ) j print( 'The server year is ' .. Time.GetYear( t ) .. ) See Also None Time.lsValid Brief Check if a stored date/time value represents a valid date and time. Definition boolean Time.IsValid(Time time) Arguments time - The Time object to check. Return Values True if the date and time contain valid values, or false if not. Description Since 1.70 the Time object will no longer internally enforce that the stored value is always valid. The validity will only be checked if attempting to perform arithmetic (Add* or GetDifference* functions) or convert the time between time zones or formats. If you wish to check a time for validity without generating a Lua error this function can be used, and will check that the date/time value represents a valid date and time, taking account of leap years where appropriate. Examples if (not myTime:IsValid()) then myTime:SetFromServer() — revert to a valid time end See Also None Time.SetDayOfMonth Brief Sets the day of the month value. Definition Time.SetDayOfMonth( Time time, number value ) Arguments time - The time object to update.value - The day of the month value, ranging from 1 to 31. Return Values None Description Sets the day of the month value. Examples j t = Time.Create() ! Time.SetDayOfMonth( t, 29 ) \ print( 'The server day of the month is ' .. Time.GetDayOfMonth( t ) .. ) See Also None Time.SetFromLocal Brief Sets the time object to the current local time of the PlayStation(R)3. Definition boolean Time.SetFromLocal( Time time ) Arguments time - The time object to update. Return Values true if successful and false otherwise. Description Sets the time object to the current local time of the PlayStation(R)3. This is the time the user has set their PlayStation(R)3 to. Examples j t = Time.Create() j Time.SetFromLocal( t ) print ( 'The time is ' .. Time.GetTime( t ) .. ) See Also None Time.SetFromPosixTimestamp Brief Convert a POSIX-compatible 64-bit timestamp into a Time value. Definition Time.SetFromPosixTimestamp(Time t, Biglnt<64> timestamp) Arguments t - Time object to modify.timestamp - A 64-bit Biglnt value containing the timestamp. Return Values Description Converts a POSIX-compatible 64-bit timestamp (time_t) into a Time value. Examples ! local timestamp = Biglnt.Create (64) ? ReadTimestampFromExternalSource(timestamp) local t = Time.Create() ! t:SetFromPosixTimestamp(timestamp) See Also Time.GetAsPosixTimestamp Time.SetFromServer Brief Sets the time object to the current server time. Definition boolean Time.SetFromServer( Time time ) Arguments time - The time object to update. Return Values true if successful and false otherwise. Description Sets the time object to the current server time. The time object is not automatically updated with the server time so you must call it every time you want to refresh it. The server time is independent of the PlayStation(R)3 region or local time settings and always returns UTC (Coordinated Universal Time). Note that the Home client does not need to be run in online mode for this function to work. However, the target machine must be signed in to the PSN. Examples t = Time.Create() Time .SetFromServer( t ) print( 'The time is ' .. Time.GetTime( t ) .. ) See Also None Time.SetHour Brief Sets the hour value. Definition Time.SetHour( Time time, number value ) Arguments time - The time object to update.value - The hour value, ranging from 0 to 23. Return Values None Description Sets the hour value. Examples t = Time.Create() Time .SetHour( t, 12 ) print( 'The server hour is ' .. Time.GetHour( t ) .. ) See Also None Time.SetMinute Brief Sets the minute value. Definition Time.SetMinute( Time time, number value ) Arguments time - The time object to update.value - The minute value, ranging from 0 to 59. Return Values None Description Sets the minute value. Examples j t = Time.Create() i Time.SetMinute( t, 55 ) j print ( 'The server minute is ' .. Time.GetMinute ( t ) .. '.' ) See Also None Time.SetMonth Brief Sets the month value. Definition Time.SetMonth( Time time, number value ) Arguments time - The time object to update.value - The month value, ranging from 1 to 12. Return Values None Description Sets the month value. Examples t = Time.Create() Time.SetMonth( t, 12 ) print( 'The server month is ' .. Time.GetMonth( t ) .. '.' ) See Also None Time.SetSecond Brief Sets the second value. Definition Time.SetSecond( Time time, number value ) Arguments time - The time object to update.value - The second value, ranging from 0 to 59. Return Values None Description Sets the second value. Examples ! t = Time.Create() ! Time.SetSecond( t, 12 ) j print( 'The server second is ' .. Time.GetSecond( t ) .. '.' ) See Also None Time.SetYear Brief Sets the year value. Definition Time.SetYear( Time time, number value ) Arguments time - The time object to update.value - The year value, ranging from 0 to 9999. Return Values None Description Sets the year value. Examples j t = Time.Create() i Time.SetYear( t, 1066 ) j print( 'The server year is ' .. Time.GetYear( t ) .. ) See Also None