Tương tác giữa PHP và jQuery - part 29

CHAPTER 8 ■ EDITING THE CALENDAR WITH AJAX AND JQUERY "deserialize" : function(str){.}, "urldecode" : function(str) {.} }; Fixing Timezone Inconsistencies You aren’t passing a time or timezone to the Date object, so that object will default to midnight Greenwich Mean Time (00:00:00 GMT). This can cause your dates to behave unexpectedly for users in different timezones. To address this problem, you’ll need to adjust the date by the timezone offset using two built-in Date object methods: .setMinutes() and .getTimezoneOffset(). The return value of .getTimezoneOffset() is the difference in the number of minutes between GMT and the user’s timezone. For instance, the return. | CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY deserialize function str . urldecode function str . Fixing Timezone Inconsistencies You aren t passing a time or timezone to the Date object so that object will default to midnight Greenwich Mean Time 00 00 00 GMT . This can cause your dates to behave unexpectedly for users in different timezones. To address this problem you ll need to adjust the date by the timezone offset using two built-in Date object methods .setMinutes and .getTimezoneOffset . The return value of .getTimezoneOffset is the difference in the number of minutes between GMT and the user s timezone. For instance the return value of .getTimezoneOffset in Mountain Standard Time -0700 is 420. Using .setMinutes you can add the value of the timezone offset to the Date object which will return the date to midnight on the given day no matter what timezone the user is in. You can make that adjustment using the following bold code fx initModal function . boxin function data modal . boxout function event . Adds a new event to the markup after saving addevent function data formData Converts the query string to an object var entry formData Makes a date object for current month cal new Date NaN Makes a date object for the new event event new Date NaN Extracts the event day month and year date 0 Splits the event data into pieces edata - Extracts the calendar month from the H2 ID cdata h2 .attr id .split - Sets the date for the calendar date object cdata 1 cdata 2 1 Sets the date for the event date object edata 0 edata 1 edata 2 Since the date object is created using 281 CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY GMT then adjusted for the local timezone adjust the offset to ensure a proper date deserialize function str . urldecode function str . Ensuring the Event Occurs in the Current Month Your next step is to set up a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.